home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / renderWindowPanel.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  100.2 KB  |  4,056 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  September 16, 1998
  22. //
  23. // Description:
  24. //
  25. //        Creates a panel that contains the rendering window.
  26. //        This file also contains a bunch of helper procedures related to the
  27. //        rendering window.
  28. //
  29.  
  30.  
  31. // This file is organized in the following order.
  32. //
  33. // - Utility procedures used by other procedures in the file
  34. // - Procedures called when menu commands are chosen
  35. // - Procedures which generate the menus and refresh the menus each time the
  36. // particular menu is opened
  37. // - Procedures which call the menu generation procedures and create other
  38. // user interface elements within the render view window or panel
  39. // - Procedures which are accessed from outside the renderview
  40. // - Procedures which support scripted panel capability
  41. //
  42. // Conventions:
  43. //
  44. // - $editor is the name of the scripted panel object which is the render view
  45. // panel
  46.  
  47. global int $gIprTuningPaused = false;
  48.  
  49. //----------------------------------------------------------------------------//
  50. // Utility procedures
  51. //----------------------------------------------------------------------------//
  52.  
  53.  
  54. //
  55. // Description:
  56. //        Sets all the option var specific to the render view.
  57. //    - renderViewTestResolution: 0 => panel resolution.
  58. //                                1 => render globals.
  59. //                                2 => 50% render globals.
  60. //                                3 => 25% render globals.
  61. //                                4 => 10% render globals.
  62. //    - renderViewAutoResize: boolean
  63. //    - renderViewAutoRenderRegion: boolean.
  64. //
  65. global int $renderViewShadowsMode = 0;
  66. global int $renderViewGlowPassMode = 0;
  67. global proc setRenderOptionVars()
  68. {
  69.     if( !`optionVar -exists renderViewTestResolution` )
  70.     {
  71.         // Default value: 1 => render globals
  72.         //
  73.         optionVar -intValue renderViewTestResolution 1;
  74.     }
  75.     if( !`optionVar -exists renderViewAutoResize` )
  76.     {
  77.         optionVar -intValue renderViewAutoResize 1;
  78.     }
  79.     if( !`optionVar -exists renderViewAutoRenderRegion` )
  80.     {
  81.         optionVar -intValue renderViewAutoRenderRegion 0;
  82.     }
  83.  
  84.     // For the long run, we should add a flag to the 
  85.     // renderWindowEditor which will allow us to associate
  86.     // a file name with an image.
  87.     // Also, we should make sure that each image in the
  88.     // renderview buffer can have a name associated with it.
  89.     // (code reivew comments from Josh, Sept. 15, Corina Wang)
  90.     //
  91.     if( !`optionVar -exists renderedImageName` )
  92.     {
  93.         optionVar -stringValue renderedImageName "test";
  94.     }
  95.  
  96.     // IPR option variables which don't depend on the iprEngine
  97.     //
  98.  
  99.     if( !`optionVar -exists iprRenderShading` )
  100.     {
  101.         optionVar -intValue iprRenderShading true;
  102.     }
  103.     if( !`optionVar -exists iprRenderShadowMaps` )
  104.     {
  105.         optionVar -intValue iprRenderShadowMaps true;
  106.     }
  107.     if( !`optionVar -exists iprRenderMotionBlur` )
  108.     {
  109.         optionVar -intValue iprRenderMotionBlur true;
  110.     }
  111. }
  112.  
  113. //
  114. // Description:
  115. //        Returns the render window editor, creates it if needed.
  116. //
  117. proc string getRenderWindowPanel()
  118. {
  119.     string $renderPanel;
  120.     string $renderPanels[] = `getPanel -scriptType "renderWindowPanel"`;
  121.  
  122.     if( size($renderPanels) == 0 )
  123.     {
  124.         $renderPanel = `scriptedPanel -type "renderWindowPanel" -unParent`;
  125.         scriptedPanel -e -label `interToUI $renderPanel` $renderPanel;
  126.     }
  127.     else
  128.     {
  129.         $renderPanel = $renderPanels[0];
  130.     }
  131.  
  132.     return $renderPanel;
  133. }
  134.  
  135. proc int isIprFileLoaded()
  136. {
  137.     // Returns 1 if the active image has a ipr image behind it.
  138.     //
  139.     if (`iprEngine -query -exists defaultIprEngine`) {
  140.  
  141.         string $iprImageName[] = `iprEngine -q -iprImage defaultIprEngine`;
  142.         if (size($iprImageName) > 0)
  143.             if ($iprImageName[0] != "")
  144.                 return true;
  145.     }
  146.     return false;
  147. }
  148.  
  149. proc initializeIprOptionVars(string $iprEngine)
  150. //
  151. // Description:
  152. //        Sets all the option vars specific to IPR.
  153. //
  154. {
  155.     //
  156.     //    Set the options variables.
  157.     //
  158.     if( !`optionVar -exists updateShadingAndLighting` ) 
  159.     {
  160.         optionVar -intValue updateShadingAndLighting 1;
  161.     }
  162.     if( !`optionVar -exists updateLightGlow` ) 
  163.     {
  164.         optionVar -intValue updateLightGlow 1;
  165.     }
  166.     if( !`optionVar -exists updateShaderGlow` ) 
  167.     {
  168.         optionVar -intValue updateShaderGlow 1;
  169.     }
  170.     if( !`optionVar -exists updateMotionBlur` ) 
  171.     {
  172.         optionVar -intValue updateMotionBlur 1;
  173.     }
  174.  
  175.     // Set the state on the engine.
  176.     //
  177.     iprEngine -edit
  178.         -updateShading      `optionVar -query updateShadingAndLighting`
  179.         $iprEngine;
  180.  
  181.     iprEngine -edit
  182.         -updateLightGlow     `optionVar -query updateLightGlow`
  183.         $iprEngine;
  184.  
  185.     iprEngine -edit
  186.         -updateShaderGlow     `optionVar -query updateShaderGlow`
  187.         $iprEngine;
  188.  
  189.     iprEngine -edit
  190.         -updateMotionBlur     `optionVar -query updateMotionBlur`
  191.         $iprEngine;
  192. }
  193.  
  194. global proc updateIPRMemoryEstimate()
  195. {
  196.     string $displayedMemory = "IPR: ";
  197.  
  198.     if (isIprFileLoaded()) {
  199.         string $memEstimate[] = 
  200.             `iprEngine -q -estimatedMemory defaultIprEngine`;
  201.  
  202.         if ($memEstimate[0] == "0MB") {            
  203.             // Prompt the user to select a region to begin tuning
  204.             //
  205.             renderWindowEditor 
  206.                 -edit
  207.                 -caption "Select a region to begin tuning"
  208.                 `getRenderWindowPanel`;
  209.         }
  210.  
  211.         $displayedMemory = ($displayedMemory + $memEstimate[0]);
  212.     } else {
  213.         $displayedMemory = ($displayedMemory + "0MB");
  214.     }
  215.  
  216.     text -edit -label $displayedMemory iprMemEstText;
  217. }
  218.  
  219. proc beginIprSession(string $editor)
  220. {
  221.     if (!`iprEngine -query -exists defaultIprEngine`)
  222.     {
  223.         // Create an IPR engine
  224.         //
  225.         iprEngine defaultIprEngine;
  226.  
  227.         // Set the state on this engine using optionVars.
  228.         initializeIprOptionVars "defaultIprEngine";
  229.  
  230.         // Set the flag indicating whether IPR tuning is paused
  231.         //
  232.         global int $gIprTuningPaused;
  233.         $gIprTuningPaused = false;
  234.         renderWindowRefreshMenu("ipr", $editor);
  235.     }
  236.  
  237.     scriptJob 
  238.         -parent $editor
  239.         -replacePrevious
  240.         -event SceneOpened ("renderWindowMenuCommand closeIprFile " + $editor);
  241. }
  242.  
  243. proc endIprSession(string $editor)
  244. {
  245.     // Delete the IPR engine
  246.     //
  247.     if (isIprFileLoaded()) {
  248.         iprEngine
  249.             -edit
  250.             -releaseIprImage
  251.             defaultIprEngine;
  252.  
  253.         deleteUI defaultIprEngine;
  254.     }
  255.  
  256.     // Delete the IPR default light, if there is one.  If there is indeed one,
  257.     // it will be the directional light with the dynamic attribute
  258.     // isIPRDefaultLight.
  259.     //
  260.  
  261.     string $directionalLights[] = `ls -type directionalLight`;
  262.  
  263.     string $light;
  264.  
  265.     for ($light in $directionalLights)
  266.     {
  267.         if (`objExists ($light + ".isIPRDefaultLight")`)
  268.         {
  269.             // Delete the transform (i.e., parents[0]), not just the light,
  270.             // and make sure it doesn't go on undo queue.
  271.             //
  272.             string $parents[] = `listRelatives -parent $light`;
  273.             int $undoOn = `undoInfo -query -swf`;
  274.             if ($undoOn)
  275.                 undoInfo -swf off;
  276.             
  277.             delete $parents[0];
  278.             if ($undoOn)
  279.                 undoInfo -swf on;
  280.             
  281.             break;
  282.         }
  283.     }
  284.  
  285.  
  286.     // Update the memory estimate.
  287.     //
  288.     updateIPRMemoryEstimate();
  289.  
  290.     // Set the flag indicating whether IPR tuning is paused
  291.     //
  292.     global int $gIprTuningPaused;
  293.     $gIprTuningPaused = false;
  294.     renderWindowRefreshMenu("ipr", $editor);
  295. }
  296.  
  297. proc unloadSamples(string $editor)
  298. {
  299.     // Update the UI to indicate that no samples are loaded
  300.     //
  301. }
  302.  
  303. proc int isImageLoaded(string $editor)
  304. {
  305.     return (`renderWindowEditor -query -nbImages $editor` != -1);
  306. }
  307.  
  308. proc string changeWorkspaceDir(string $newDirType)
  309. {
  310.     string    $rootDir            = `workspace -query -rootDirectory`;
  311.     string    $currentDir            = `workspace -query -directory`;
  312.     string    $renderDirs[]        = `workspace -query -renderType`;
  313.     string    $newDir                = $currentDir;
  314.  
  315.     int $i;
  316.     for ($i = 0; $i < size($renderDirs); $i += 2)
  317.     {
  318.         if ($renderDirs[$i] == $newDirType)
  319.         {
  320.             $newDir = $renderDirs[$i+1];
  321.         }
  322.     }
  323.  
  324.     workspace -directory $rootDir;
  325.     workspace -directory $newDir;
  326.     return $currentDir;
  327. }
  328.  
  329. proc int[] getGlobalsResolution()
  330. {
  331.     //
  332.     //    Render globals item.
  333.     //
  334.     string    $globals[] = `ls -renderGlobals`;
  335.     int        $res[2] = { 320, 240 };
  336.  
  337.     if( size($globals[0]) > 0 )
  338.     {
  339.         string    $connect[] = `listConnections ($globals[0] + ".resolution")`;
  340.  
  341.         if( size($connect[0]) > 0 )
  342.         {
  343.             $res[0] = `getAttr ($connect[0] + ".width" )`;
  344.             $res[1] = `getAttr ($connect[0] + ".height" )`;
  345.         }
  346.     }
  347.  
  348.     return $res;
  349. }
  350.  
  351. // Description:  Get the test resolution for the current renderer.
  352. //
  353. proc int[] getTestResolution( string $panel )
  354. {
  355.     int        $res[2] = { 320, 240 };
  356.  
  357.     if( `optionVar -exists renderViewTestResolution` )
  358.     {
  359.         $testRes = `optionVar -query renderViewTestResolution`;
  360.  
  361.         if( $testRes == 0 )
  362.         {
  363.             if( size($panel) )
  364.             {
  365.                 string    $modelViewControl = `modelEditor -q -control $panel`;
  366.  
  367.                 if( size($modelViewControl) && `control -ex $modelViewControl` )
  368.                 {
  369.                     $res[0] = `control -q -w $modelViewControl`;
  370.                     $res[1] = `control -q -h $modelViewControl`;
  371.                 }
  372.             }
  373.         }
  374.         else
  375.         {
  376.             string $hasCommonGlobalValueProc =
  377.                 `renderer -query -hasCommonGlobalValueProcedure (currentRenderer())`;
  378.             string $getCommonGlobalValueProc =
  379.                 `renderer -query -getCommonGlobalValueProcedure (currentRenderer())`;
  380.  
  381.             if( $hasCommonGlobalValueProc != "" &&
  382.                 $getCommonGlobalValueProc != "" &&
  383.                 eval($hasCommonGlobalValueProc+" width") &&
  384.                 eval($hasCommonGlobalValueProc+" height"))
  385.             {
  386.                 // Use getCommonGlobalValueProc to get the width and height.
  387.                 //
  388.                 $res[0] = eval($getCommonGlobalValueProc+" width");
  389.                 $res[1] = eval($getCommonGlobalValueProc+" height");
  390.  
  391.                 if( $testRes == 2 )
  392.                 {
  393.                     $res[0] /= 2;
  394.                     $res[1] /= 2;
  395.                 }
  396.                 else if( $testRes == 3 )
  397.                 {
  398.                     $res[0] /= 4;
  399.                     $res[1] /= 4;
  400.                 }
  401.                 else if( $testRes == 4 )
  402.                 {
  403.                     $res[0] /= 10;
  404.                     $res[1] /= 10;
  405.                 }
  406.             }
  407.         }
  408.     }
  409.  
  410.     return $res;
  411. }
  412.  
  413. proc string getRenderWindowPanelFormLayout()
  414. {
  415.     string    $panel[] = `getPanel -scriptType "renderWindowPanel"`;
  416.     return `renderWindowEditor -query -parent $panel[0]`;
  417. }
  418.  
  419. //
  420. // Description:
  421. //        Returns the current camera stored by the render window editor.
  422. //    returns the current camera view if nothing stored in the render view or
  423. //    the first camera.
  424. //
  425. proc string getCurrentCamera()
  426. {
  427.     string    $renderPanel = `getRenderWindowPanel`;
  428.     string    $camera = `renderWindowEditor -q -currentCamera $renderPanel`;
  429.  
  430.     if( !size($camera) )
  431.     {
  432.         //
  433.         //    So gets the current camera.
  434.         //
  435.         string $currentPanel = `getPanel -wf`;
  436.  
  437.         if( `modelPanel -exists $currentPanel` )
  438.         {
  439.             $camera = `modelPanel -q -cam $currentPanel`;
  440.         }
  441.         else
  442.         {
  443.             // Since we have to make a guess at what camera to use, we'll
  444.             // first guess that it's something typical (namely: persp).
  445.             // If that's not a good guess, we'll just guess that it's the
  446.             // first camera in the scene.
  447.             //
  448.             int $useFirstCamera = true;
  449.  
  450.             string $defCameras[] = `ls persp|perspShape`;
  451.             if (size($defCameras) > 0) {
  452.                 string $defCamera = $defCameras[0];
  453.                 if (`nodeType $defCamera` == "camera") {
  454.                     $camera = $defCamera;
  455.                     $useFirstCamera = false;
  456.                 }
  457.             }
  458.  
  459.             if ($useFirstCamera) {
  460.                 string    $cameras[] = `ls -cameras`;                
  461.                 $camera = $cameras[0];
  462.             }
  463.         }
  464.     }
  465.  
  466.     return $camera;
  467. }
  468.  
  469. proc string getCameraPanel( string $camera )
  470. {
  471.     string    $cameraPanel;
  472.  
  473.     for( $modelPanel in `getPanel -type "modelPanel"` )
  474.     {
  475.         $cameraPanel = `modelPanel -q -cam $modelPanel`;
  476.  
  477.         if( $cameraPanel == $camera )
  478.         {
  479.             return $modelPanel;
  480.         }
  481.     }
  482.  
  483.     string    $null = "";
  484.     return $null;
  485. }
  486.  
  487. //
  488. // Description:
  489. //    Raise the render view window if exists, then return 1.
  490. //    Return 0 otherwise.
  491. //
  492. proc int raiseRenderViewWindow()
  493. {
  494.     //
  495.     //    Look for the renderViewWindow and pop it up if it exists.
  496.     //
  497.     for( $i in `lsUI -windows` )
  498.     {
  499.         if( $i == "renderViewWindow" )
  500.         {
  501.             showWindow $i;
  502.             return 1;
  503.         }
  504.     }
  505.  
  506.     return 0;
  507. }
  508.  
  509. proc string showRenderView()
  510. {
  511.     // Ensures that the Render View is displayed.
  512.     // If the Render View is currently torn-off in a window, the window is
  513.     // brought forward. If the Render View does not exist in a torn-off window
  514.     // nor in a panel, it is created in a torn-off window.
  515.     //
  516.     // Returns the name of the render view.
  517.     //
  518.  
  519.     string $editor;
  520.  
  521.     $editor = `getRenderWindowPanel`;
  522.  
  523.     if( `raiseRenderViewWindow` == 1 )
  524.     {
  525.         // The Render View exists and is in a torn-off window. It has been
  526.         // brought to the front.
  527.         //
  528.         return $editor;
  529.     }
  530.  
  531.     // If we get to here, the Render View is not in a torn-off window
  532.     //
  533.     for( $i in `getPanel -vis` )
  534.     {
  535.         if( $i == $editor )
  536.         {
  537.             // The Render View exists and is in a panel. 
  538.             //
  539.             return $editor;
  540.         }
  541.     }
  542.  
  543.     // If we get to here, the Render View is not currently in a panel nor is
  544.     // it in a torn-off window.
  545.     //
  546.     scriptedPanel 
  547.         -edit 
  548.         -tearOff 
  549.         $editor;
  550.     
  551.     return $editor;
  552. }
  553.  
  554. proc int isToolbarDisplayed ()
  555. {
  556.     if( `optionVar -exists renderViewDisplayToolbar` )
  557.     {
  558.         return `optionVar -query renderViewDisplayToolbar`;
  559.     }
  560.     else
  561.     {
  562.         optionVar -intValue renderViewDisplayToolbar 1;
  563.         return 1;
  564.     }
  565. }
  566.  
  567. proc displayToolbar (int $display)
  568. {
  569.     optionVar -intValue renderViewDisplayToolbar $display;
  570. }
  571.  
  572. proc toggleDisplayToolbar()
  573. {
  574.     if (isToolbarDisplayed())
  575.     {
  576.         displayToolbar(false);
  577.     }
  578.     else
  579.     {
  580.         displayToolbar(true);
  581.     }
  582. }
  583.  
  584. //----------------------------------------------------------------------------//
  585. // Procedures which are called when menu items are chosen
  586. //----------------------------------------------------------------------------//
  587.  
  588. proc loadImage(string $editor) 
  589. {
  590.     string $callbackCmd;
  591.     $callbackCmd = ("renderWindowLoadImageCallback \"" + $editor + "\"");
  592.  
  593.     string $prevDir = changeWorkspaceDir("images");
  594.  
  595.     // 0 for a read browser 
  596.     //
  597.     fileBrowser $callbackCmd  "Load Image"  "image" 0;
  598.  
  599.     changeWorkspaceDir($prevDir);
  600. }
  601.  
  602. global proc int renderWindowLoadImageCallback(
  603.     string $editor, 
  604.     string $fileName, 
  605.     string $fileType)
  606. {
  607.     // Called by the file browser with the name and type of the file the user
  608.     // has chosen
  609.     //
  610.     if ($fileName != "")
  611.     {
  612.         renderWindowEditor
  613.             -edit
  614.             -loadImage $fileName
  615.             $editor;
  616.     }
  617.  
  618.     // Return 1 to close the file browser
  619.     //
  620.     return 1;
  621. }
  622.  
  623. proc saveImage(string $editor)
  624. {
  625.     string $callbackCmd;
  626.     $callbackCmd = ("renderWindowSaveImageCallback \"" + $editor + "\"");
  627.  
  628.     string $prevDir = changeWorkspaceDir("images");
  629.  
  630.     // 1 for a write browser 
  631.     //
  632.     fileBrowser $callbackCmd  "Save Image"  "image" 1;
  633.  
  634.     changeWorkspaceDir($prevDir);
  635. }
  636.  
  637. global proc int renderWindowSaveImageCallback(
  638.     string $editor, 
  639.     string $fileName, 
  640.     string $fileType)
  641. {
  642.     // Called by the file browser with the name and type of the file the user
  643.     // has chosen
  644.     //
  645.     if ($fileName != "")
  646.     {
  647.         renderWindowEditor
  648.             -edit
  649.             -writeImage $fileName
  650.             $editor;
  651.     }
  652.  
  653.     // Return 1 to close the file browser
  654.     //
  655.     return 1;
  656. }
  657.  
  658. proc loadIprFile(string $editor) 
  659. {
  660.     string $callbackCmd;
  661.     $callbackCmd = ("renderWindowLoadIprFileCallback \"" + $editor + "\"");
  662.  
  663.     string $prevDir = changeWorkspaceDir("iprImages");
  664.  
  665.     // 0 for a read browser 
  666.     //
  667.     fileBrowser $callbackCmd  "Load IPR File"  "iff" 0;
  668.  
  669.     changeWorkspaceDir($prevDir);
  670. }
  671.  
  672. proc closeIprFile(string $editor)
  673. {
  674.     unloadSamples($editor);
  675.     endIprSession($editor);
  676. }
  677.  
  678. global proc int renderWindowLoadIprFileCallback(
  679.     string $editor, 
  680.     string $fileName, 
  681.     string $fileType)
  682. {
  683.     // Called by the file browser with the name and type of the file the user
  684.     // has chosen
  685.     //
  686.     if ($fileName != "")
  687.     {
  688.         // Now that we have an IPR file, we can enable IPR
  689.         //
  690.         beginIprSession($editor);
  691.  
  692.         // Register the file with the IPR engine
  693.         //
  694.         iprEngine
  695.             -edit
  696.             -iprImage $fileName
  697.             defaultIprEngine;
  698.  
  699.         // Prompt the user to select a region to begin tuning
  700.         //
  701.         renderWindowEditor 
  702.             -edit
  703.             -caption "Select a region to begin tuning"
  704.             $editor;
  705.  
  706.         // Update UI which needs to be changed
  707.         //
  708.         renderWindowRefreshLayout($editor);
  709.         renderWindowRefreshMenu("file", $editor);
  710.         renderWindowRefreshMenu("ipr", $editor);
  711.     }
  712.  
  713.     // Return 1 to close the file browser
  714.     //
  715.     return 1;
  716. }
  717.  
  718. proc saveIprFile(string $editor)
  719. {
  720.     string $callbackCmd;
  721.     $callbackCmd = ("renderWindowSaveIprFileCallback \"" + $editor + "\"");
  722.  
  723.     string $prevDir = changeWorkspaceDir("iprImages");
  724.     string $workspace = `workspace -fn`;
  725.  
  726.     // 1 for a write browser 
  727.     //
  728.     fileBrowser $callbackCmd  "Save IPR File"  "iff" 2;
  729.  
  730.     changeWorkspaceDir($prevDir);
  731. }
  732.  
  733. global proc int renderWindowSaveIprFileCallback(
  734.     string $editor, 
  735.     string $inFileName, 
  736.     string $fileType)
  737. {
  738.     // Called by the file browser with the name and type of the file the user
  739.     // has chosen
  740.     //
  741.     if ($inFileName != "")
  742.     {
  743.         // Expand the filename to its full name.
  744.         string $fileName = `workspace -expandName $inFileName`;
  745.  
  746.         if (isIprFileLoaded()) {
  747.             // copy the current ipr file to the specified fileName        
  748.             iprEngine -edit -copy $inFileName defaultIprEngine;
  749.         }
  750.     }
  751.  
  752.     // Return 1 to close the file browser
  753.     //
  754.     return 1;
  755. }
  756.  
  757. global proc renderWindowRenderCamera(
  758.     string     $renderMode, 
  759.     string     $editor, 
  760.     string     $camera)
  761. {
  762.     global int $renderViewShadowsMode;
  763.     global int $renderViewGlowPassMode;
  764.  
  765.     // Ensure we have someplace to render to...
  766.     //
  767.     if ($editor == "")
  768.     {
  769.         $editor = `showRenderView`;
  770.     }
  771.     
  772.     // Cancel the Hypershade snapshot if it is still going
  773.     // 
  774.     if (`renderWindowEditor -query -snapshotMode $editor`) {
  775.         renderWindowMenuCommand("grabSwatch", $editor);
  776.     }
  777.  
  778.     if (isIprFileLoaded()) {
  779.         // The user has asked to for another render and they already
  780.         // have an IPR file loaded, ask the user if they are sure they
  781.         // want to do this.
  782.         //
  783.         // We cannot do another IPR render if we are still tuning.
  784.  
  785.         renderWindowMenuCommand "closeIprFile" $editor;
  786.     }
  787.  
  788.     // Valid arguments for renderMode are:
  789.     // "redoPreviousRender", "renderRegion", "render", "snapshot",
  790.     // "redoPreviousIprRender", or "iprRender".
  791.  
  792.     // Determine the camera to render from.
  793.     //
  794.     // If the camera to render from has not been specified, we 
  795.     // render from the current camera.
  796.     //
  797.     if ($camera == "")
  798.     {
  799.         $camera     = `getCurrentCamera`;
  800.     }
  801.  
  802.     string    $cameraPanel    = `getCameraPanel( $camera )`;
  803.     int     $resolution[]     = `getTestResolution( $cameraPanel )`;
  804.     string    $globals[]         = `ls -renderGlobals`;
  805.  
  806.     // Save the current render region setting of the render globals
  807.     //
  808.     int     $prevUseRenderRegion = 
  809.         `getAttr ($globals[0] + ".useRenderRegion")`;
  810.  
  811.     // Determine the resolution to render at.
  812.     //
  813.     if (($renderMode == "renderRegion"))
  814.     {
  815.         setAttr ($globals[0] + ".useRenderRegion") true;
  816.  
  817.         //
  818.         //    Show the region.
  819.         //
  820.             renderWindowEditor 
  821.                 -edit 
  822.                 -showRegion $resolution[0] $resolution[1] 
  823.                 $editor;
  824.     }
  825.     else
  826.     {
  827.         setAttr ($globals[0] + ".useRenderRegion") false;
  828.     }
  829.  
  830.     // Perform the render
  831.     //
  832.     string $result;
  833.  
  834.     if ($renderMode == "snapshot")
  835.     {
  836.         renderWindowTakeSnapshot( $resolution[0], $resolution[1], $camera );
  837.     }
  838.     else if (($renderMode == "iprRender")
  839.              || ($renderMode == "redoPreviousIprRender"))
  840.     {
  841.         //
  842.         // Make sure at least one of the IPR Render options is enabled,
  843.         // or else doing an IPR render would be useless
  844.         //
  845.         int $doShading = `optionVar -query iprRenderShading`;
  846.         int $doBlur = `optionVar -query iprRenderMotionBlur`;
  847.  
  848.         if (!$doShading && !$doBlur) {
  849.             warning("IPR Render requires at least one of the following options enabled:");
  850.             print("    Render Shading, Lighting and Glow\n");
  851.             print("    Render 2D Motion Blur\n");
  852.             warning(
  853.                 "Turn on at least one of these options in IPR Options in Render Global Settings.");
  854.             return;
  855.         }
  856.  
  857.         // Save the current render global IPR settings
  858.         //
  859.         int $prevCreateIprFile =
  860.             `getAttr ($globals[0] + ".createIprFile")`;
  861.         int $prevIprRenderShading =
  862.             `getAttr ($globals[0] + ".iprRenderShading")`;
  863.         int $prevIprRenderShadowMaps =
  864.             `getAttr ($globals[0] + ".iprRenderShadowMaps")`;
  865.         int $prevIprRenderMotionBlur =
  866.             `getAttr ($globals[0] + ".iprRenderMotionBlur")`;
  867.  
  868.         setAttr ($globals[0]+".createIprFile")
  869.             true;
  870.         setAttr ($globals[0]+".iprRenderShading")
  871.             `optionVar -query iprRenderShading`;
  872.         setAttr ($globals[0]+".iprRenderShadowMaps")
  873.             `optionVar -query iprRenderShadowMaps`;
  874.         setAttr ($globals[0]+".iprRenderMotionBlur")
  875.             `optionVar -query iprRenderMotionBlur`;
  876.  
  877.         // Perform the IPR render
  878.         //
  879.         int $doShadows = !$renderViewShadowsMode;
  880.         int $doGlowPass = !$renderViewGlowPassMode;
  881.  
  882.  
  883.         string $command;
  884.         int $renderError;
  885.  
  886.         string $renderer;
  887.  
  888.         $renderer = currentRenderer();
  889.  
  890.         if (`renderer -query -iprRenderProcedure $renderer` != "") 
  891.         {
  892.             $command = `renderer -query -iprRenderProcedure $renderer`;
  893.             $renderError = catch( 
  894.                 $result = 
  895.                     `eval $command 
  896.                         $resolution[0] 
  897.                         $resolution[1] 
  898.                         $doShadows 
  899.                         $doGlowPass 
  900.                         $camera`
  901.             );
  902.  
  903.             string $currentRendererName = currentRenderer();
  904.             string $renUIName = `renderer -query -rendererUIName $currentRendererName`;
  905.             renderWindowEditor 
  906.                 -edit 
  907.                 -pca $renUIName 
  908.                 $editor;
  909.         }
  910.         else
  911.         {
  912.             string $renUIName = `renderer -query -rendererUIName $renderer`;
  913.             warning
  914.                 ("Current Renderer " 
  915.                     + $renUIName
  916.                     + " does not support IPR");
  917.             $renderError = true;
  918.         }
  919.  
  920.         // Reset the IPR setting
  921.         //
  922.         setAttr ($globals[0] + ".createIprFile") $prevCreateIprFile;
  923.         setAttr ($globals[0] + ".iprRenderShading") $prevIprRenderShading;
  924.         setAttr ($globals[0] + ".iprRenderShadowMaps") $prevIprRenderShadowMaps;
  925.         setAttr ($globals[0] + ".iprRenderMotionBlur") $prevIprRenderMotionBlur;
  926.  
  927.         if (!$renderError) {
  928.             // Tell the IPR engine about the IPR file which has just
  929.             // been created.
  930.             //
  931.             renderWindowLoadIprFileCallback($editor, $result, "");
  932.  
  933.             renderWindowRefreshLayout($editor);
  934.  
  935.             // Prompt the user to select a region to begin tuning
  936.             //
  937.             renderWindowEditor 
  938.                 -edit
  939.                 -caption "Select a region to begin tuning"
  940.                 $editor;
  941.  
  942.             // If we have rendered an IPR image without motion blur, turn off
  943.             // update motion blur on the IPR engine. Otherwise, set update 
  944.             // motion blur according to the user's choice in the IPR->IPR 
  945.             // Tuning Options menu.
  946.             // If we didn't turn off update motion blur when there is no motion
  947.             // blur, Pause IPR Tuning would prevent swatches from being updated.
  948.             //
  949.             if ($doBlur)
  950.             {
  951.                 iprEngine -edit
  952.                     -updateMotionBlur     `optionVar -query updateMotionBlur`
  953.                     defaultIprEngine;
  954.             }
  955.             else
  956.             {
  957.                 iprEngine -edit
  958.                     -updateMotionBlur     false
  959.                     defaultIprEngine;
  960.             }
  961.         }
  962.     }
  963.     else
  964.     {
  965.         int $prevCreateIprFile = `getAttr ($globals[0] + ".createIprFile")`;
  966.         setAttr ($globals[0]+".createIprFile") false;
  967.  
  968.         int $doShadows = !$renderViewShadowsMode;
  969.         int $doGlowPass = !$renderViewGlowPassMode;
  970.  
  971.         string $feature;
  972.         string $command;
  973.  
  974.         string $renderer;
  975.  
  976.         $feature = "render";
  977.         $renderer = currentRenderer();
  978.  
  979.         if (`renderer -query -renderProcedure $renderer` != "") 
  980.         {
  981.             $command = `renderer -query -renderProcedure $renderer`;
  982.  
  983.             catch($result = 
  984.                 `eval 
  985.                     $command 
  986.                     $resolution[0] 
  987.                     $resolution[1] 
  988.                     $doShadows 
  989.                     $doGlowPass 
  990.                     $camera`);
  991.  
  992.             string $currentRendererName = currentRenderer();
  993.             string $renUIName = `renderer -query -rendererUIName $currentRendererName`;
  994.             renderWindowEditor 
  995.                 -edit 
  996.                 -pca $renUIName 
  997.                 $editor;
  998.         }
  999.         else
  1000.         {
  1001.             string $renUIName = `renderer -query -rendererUIName $renderer`;
  1002.             warning
  1003.                 ("Current Renderer " 
  1004.                     + $renUIName
  1005.                     + " does not support " 
  1006.                     + $feature);
  1007.         }
  1008.  
  1009.  
  1010.         setAttr ($globals[0] + ".createIprFile") $prevCreateIprFile;
  1011.     }
  1012.  
  1013.     optionVar -stringValue renderedImageName $result;
  1014.  
  1015.     // Reset the render region setting
  1016.     //
  1017.     setAttr ($globals[0] + ".useRenderRegion") $prevUseRenderRegion;
  1018. }
  1019.  
  1020. global proc renderWindowRender(
  1021.     string     $renderMode, 
  1022.     string     $editor) 
  1023. {
  1024.     renderWindowRenderCamera($renderMode, $editor, "");
  1025. }
  1026.  
  1027. //
  1028. // Description:
  1029. //        Take a snapshot by creating a temporary model editor whithin the
  1030. //    render view window.
  1031. //
  1032. global proc renderWindowTakeSnapshot
  1033.  ( int        $resX,
  1034.    int        $resY,
  1035.    string    $camera )
  1036. {
  1037.     //
  1038.     //    Raise the render view in case it's partially covered.
  1039.     //
  1040.     raiseRenderViewWindow;
  1041.  
  1042.     string    $prevParent = `setParent -q`;
  1043.     string    $mainForm = `getRenderWindowPanelFormLayout`;
  1044.  
  1045.     setParent $mainForm;
  1046.  
  1047.     int        $formX = `formLayout -q -w $mainForm`;
  1048.     int        $formY = `formLayout -q -h $mainForm`;
  1049.     float    $snapX = $resX;
  1050.     float    $snapY = $resY;
  1051.  
  1052.     //
  1053.     //    TODO: Not very clean, to be improved.
  1054.     //
  1055.     while( $snapX > $formX )
  1056.     {
  1057.         $snapX *= 0.8;
  1058.         $snapY *= 0.8;
  1059.     }
  1060.  
  1061.     while( $snapY > $formY )
  1062.     {
  1063.         $snapX *= 0.8;
  1064.         $snapY *= 0.8;
  1065.     }
  1066.  
  1067.     int    $right = ($formX - $snapX);
  1068.     int    $bottom = ($formY - $snapY);
  1069.  
  1070.     //
  1071.     //    Create the model editor at the right size and take a snapshot.
  1072.     //
  1073.     modelEditor renderWindowTMPModelEditor;
  1074.  
  1075.     formLayout -e -af renderWindowTMPModelEditor left 0 $mainForm;
  1076.     formLayout -e -af renderWindowTMPModelEditor right $right $mainForm;
  1077.     formLayout -e -af renderWindowTMPModelEditor top 0 $mainForm;
  1078.     formLayout -e -af renderWindowTMPModelEditor bottom $bottom $mainForm;
  1079.  
  1080.     //
  1081.     //    Unset camera gates and reset overscan to 1.
  1082.     //
  1083.     int        $dfg = `camera -q -displayFilmGate $camera`;
  1084.     int        $dr = `camera -q -displayResolution $camera`;
  1085.     float    $os = `camera -q -overscan $camera`;
  1086.  
  1087.     camera -e -displayFilmGate off -displayResolution off -overscan 1.0 $camera;
  1088.  
  1089.     //
  1090.     //    Set the right camera to the model editor.
  1091.     //
  1092.     modelEditor -e -cam $camera renderWindowTMPModelEditor;
  1093.  
  1094.     //
  1095.     //    Ask the render window editor to take the snapshot of the given
  1096.     //    modelEditor at the given resolution.
  1097.     //
  1098.     string    $renderPanel = `getRenderWindowPanel`;
  1099.  
  1100.     renderWindowEditor -e -snp renderWindowTMPModelEditor $resX $resY $renderPanel;
  1101.  
  1102.     setParent $mainForm;
  1103.     deleteUI -ed renderWindowTMPModelEditor;
  1104.  
  1105.     //
  1106.     //    Restore camera settings.
  1107.     //
  1108.     camera -e -displayFilmGate $dfg -displayResolution $dr -overscan $os $camera;
  1109.  
  1110.     //
  1111.     //    Restore parent state.
  1112.     //
  1113.     setParent $prevParent;
  1114. }
  1115.  
  1116. global proc showRenderGlobals()
  1117. {
  1118.     string $globals[] = `ls -renderGlobals`;
  1119.     showEditor $globals[0];
  1120. }
  1121.  
  1122. global proc switchAutoRenderRegionVar()
  1123. {
  1124.     if( `optionVar -exists renderViewAutoRenderRegion` )
  1125.     {
  1126.         if( `optionVar -query renderViewAutoRenderRegion` != 0 )
  1127.         {
  1128.             optionVar -intValue renderViewAutoRenderRegion 0;
  1129.         }
  1130.         else
  1131.         {
  1132.             optionVar -intValue renderViewAutoRenderRegion 1;
  1133.         }
  1134.     }
  1135.     else
  1136.     {
  1137.         optionVar -intValue renderViewAutoRenderRegion 0;
  1138.     }
  1139. }
  1140.  
  1141. global proc switchAutoResizeVar( string $editor )
  1142. {
  1143.     if( `optionVar -exists renderViewAutoResize` )
  1144.     {
  1145.         if( `optionVar -query renderViewAutoResize` != 0 )
  1146.         {
  1147.             optionVar -intValue renderViewAutoResize 0;
  1148.         }
  1149.         else
  1150.         {
  1151.             optionVar -intValue renderViewAutoResize 1;
  1152.         }
  1153.     }
  1154.     else
  1155.     {
  1156.         optionVar -intValue renderViewAutoResize 1;
  1157.     }
  1158.  
  1159.     $var = `optionVar -q renderViewAutoResize`;
  1160.  
  1161.     renderWindowEditor -e -ar $var $editor;
  1162. }
  1163.  
  1164. global proc switchShadowsVar( string $editor )
  1165. {
  1166.     global int $renderViewShadowsMode;
  1167.  
  1168.     if ($renderViewShadowsMode)
  1169.     {
  1170.         $renderViewShadowsMode = 0;
  1171.     }
  1172.     else
  1173.     {
  1174.         $renderViewShadowsMode = 1;
  1175.     }
  1176. }
  1177.  
  1178. global proc switchGlowPassVar( string $editor )
  1179. {
  1180.     global int $renderViewGlowPassMode;
  1181.  
  1182.     if ($renderViewGlowPassMode) 
  1183.     {
  1184.         $renderViewGlowPassMode = 0;
  1185.     }
  1186.     else
  1187.     {
  1188.         $renderViewGlowPassMode = 1;
  1189.     }
  1190. }
  1191.  
  1192. global proc setTestResolutionVar( int $choice )
  1193. {
  1194.     if( `optionVar -exists renderViewTestResolution` &&
  1195.         $choice >= 0 && $choice <= 4 )
  1196.     {
  1197.         optionVar -intValue renderViewTestResolution $choice;
  1198.     }
  1199.     else
  1200.     {
  1201.         //
  1202.         //    Default is panel resolution.
  1203.         //
  1204.         optionVar -intValue renderViewTestResolution 1;
  1205.     }
  1206. }
  1207.  
  1208. proc loadSamples(string $editor)
  1209. {
  1210.     // Determine what IPR sample type to load
  1211.     //
  1212.     string     $sampleType;
  1213.     
  1214.     // Cancel the Hypershade snapshot if it is still going
  1215.     // 
  1216.     if (`renderWindowEditor -query -snapshotMode $editor`) {
  1217.         renderWindowMenuCommand("grabSwatch", $editor);
  1218.     }
  1219.  
  1220.     // It can take awhile to load the samples, update the status line
  1221.     // in the render view so the user knows what is happening.
  1222.     //
  1223.  
  1224.     renderWindowEditor 
  1225.         -edit
  1226.         -caption "Loading IPR Pixels..."
  1227.         $editor;
  1228.  
  1229.     int $startedTuning = catch(
  1230.         // Tell the IPR engine to start tuning
  1231.         //
  1232.         `iprEngine
  1233.             -edit
  1234.             -startTuning 
  1235.         defaultIprEngine`
  1236.         );
  1237.  
  1238.     // Reset the caption.
  1239.     //
  1240.     
  1241.     renderWindowEditor 
  1242.         -edit
  1243.         -caption ""
  1244.         $editor;
  1245.  
  1246.     // Update the memory estimate.
  1247.     //
  1248.     updateIPRMemoryEstimate();
  1249. }
  1250.  
  1251. global proc renderWindowMenuCommand(string $command, string $editor)
  1252. //
  1253. // This procedure acts as a command dispatcher. It is the single global
  1254. // procedure which menu items need to call in order to effect commands. By
  1255. // making this the single global point of entry, all of the implementation of
  1256. // particular menu item commands can be put in local procedures and prevent
  1257. // clutter in the global namespace.
  1258. //
  1259. {
  1260.     //
  1261.     // Call necessary procedures to effect the command and call the necessary
  1262.     // procedures to refresh the UI to reflect the results of the command.
  1263.     //
  1264.  
  1265.     if ($command == "loadImage")
  1266.     {
  1267.         loadImage($editor);
  1268.         renderWindowRefreshMenu("file", $editor);
  1269.         renderWindowRefreshLayout($editor);
  1270.     }
  1271.     else if ($command == "saveImage")
  1272.     {
  1273.         saveImage($editor);
  1274.     }
  1275.     else if ($command == "loadIprFile")
  1276.     {
  1277.         loadIprFile($editor);
  1278.     }
  1279.     else if ($command == "saveIprFile")
  1280.     {
  1281.         saveIprFile($editor);
  1282.     }
  1283.     else if ($command == "closeIprFile")
  1284.     {
  1285.         closeIprFile($editor);
  1286.         renderWindowRefreshLayout($editor);
  1287.     }
  1288.     else if ($command == "togglePauseTuning")
  1289.     {
  1290.         // Toggle IPR tuning on or off.
  1291.         //
  1292.         if (`iprEngine -exists defaultIprEngine`)
  1293.         {
  1294.             global int $gIprTuningPaused;
  1295.  
  1296.             if ($gIprTuningPaused)
  1297.             {
  1298.                 // Tuning is currently paused, so we will unpause it by
  1299.                 // reenabling updating according to the current settings of
  1300.                 // the optionVars which specify which updating should be done.
  1301.                 //
  1302.                 iprEngine 
  1303.                     -edit 
  1304.                     -updateShading 
  1305.                         (`optionVar -query updateShadingAndLighting`) 
  1306.                     defaultIprEngine;
  1307.                 iprEngine 
  1308.                     -edit 
  1309.                     -updateLightGlow (`optionVar -query updateLightGlow`) 
  1310.                     defaultIprEngine;
  1311.                 iprEngine 
  1312.                     -edit 
  1313.                     -updateShaderGlow (`optionVar -query updateShaderGlow`) 
  1314.                     defaultIprEngine;
  1315.                 iprEngine 
  1316.                     -edit 
  1317.                     -updateMotionBlur (`optionVar -query updateMotionBlur`) 
  1318.                     defaultIprEngine;
  1319.  
  1320.                 $gIprTuningPaused = false;
  1321.             }
  1322.             else
  1323.             {
  1324.                 // Tuning is currently unpaused, so we will pause it by
  1325.                 // disabling updating of the various aspects of an IPR image.
  1326.                 //
  1327.                 iprEngine 
  1328.                     -edit 
  1329.                     -updateShading false
  1330.                     defaultIprEngine;
  1331.                 iprEngine 
  1332.                     -edit 
  1333.                     -updateLightGlow false
  1334.                     defaultIprEngine;
  1335.                 iprEngine 
  1336.                     -edit 
  1337.                     -updateShaderGlow false
  1338.                     defaultIprEngine;
  1339.                 iprEngine 
  1340.                     -edit 
  1341.                     -updateMotionBlur false
  1342.                     defaultIprEngine;
  1343.  
  1344.                 $gIprTuningPaused = true;
  1345.             }
  1346.         }
  1347.  
  1348.         // Issue a refresh so that the pause button on the toolbar is properly
  1349.         // updated.
  1350.         //
  1351.         renderWindowRefreshLayout($editor);
  1352.         renderWindowRefreshMenu("ipr", $editor);
  1353.     }
  1354.     else if ($command == "keepImageInRenderView")
  1355.     {
  1356.         int $currImage = `renderWindowEditor -q -displayImage $editor`;
  1357.         
  1358.         if ($currImage < 0)
  1359.         {
  1360.             renderWindowEditor -edit -saveImage $editor;
  1361.             renderWindowRefreshMenu("file", $editor);
  1362.             renderWindowRefreshLayout($editor);
  1363.         }
  1364.         else
  1365.         {
  1366.             warning("This image is already kept.");
  1367.         }
  1368.     }
  1369.     else if ($command == "removeImageFromRenderView")
  1370.     {
  1371.         int $currImage = `renderWindowEditor -q -displayImage $editor`;
  1372.         
  1373.         if ($currImage >= 0)
  1374.         {
  1375.             renderWindowEditor -edit -removeImage $editor;
  1376.             renderWindowRefreshMenu("file", $editor);
  1377.             renderWindowRefreshLayout($editor);
  1378.         }
  1379.         else
  1380.         {
  1381.             warning((
  1382.                 "Cannot remove the current image from the renderview." 
  1383.                 + " Choose a stored image instead."));
  1384.         }
  1385.     }
  1386.     else if ($command == "updateShadowMaps")
  1387.     {
  1388.         if (isIprFileLoaded())
  1389.         {
  1390.             iprEngine -edit -updateShadowMaps defaultIprEngine;
  1391.         }
  1392.     }
  1393.     else if ($command == "loadSamples")
  1394.     {
  1395.         loadSamples($editor);
  1396.     }
  1397.     else if ($command == "refreshIprImage")
  1398.     {
  1399.         refreshIprImage();
  1400.     }
  1401.     else if ($command == "updateShadingAndLighting")
  1402.     {        
  1403.         optionVar 
  1404.             -intValue updateShadingAndLighting (!`optionVar -query updateShadingAndLighting`);
  1405.         if (`iprEngine -query -exists defaultIprEngine`)
  1406.         {
  1407.             iprEngine 
  1408.                 -edit 
  1409.                 -updateShading (`optionVar -query updateShadingAndLighting`) 
  1410.                 defaultIprEngine;
  1411.         }
  1412.         renderWindowRefreshMenu("ipr", $editor);
  1413.     }
  1414.     else if ($command == "updateLightGlow")
  1415.     {
  1416.         optionVar 
  1417.             -intValue updateLightGlow (!`optionVar -query updateLightGlow`);
  1418.         if (`iprEngine -query -exists defaultIprEngine`)
  1419.         {
  1420.             iprEngine 
  1421.                 -edit 
  1422.                 -updateLightGlow (`optionVar -query updateLightGlow`) 
  1423.                 defaultIprEngine;
  1424.             renderWindowRefreshMenu("ipr", $editor);
  1425.         }
  1426.     }
  1427.     else if ($command == "updateShaderGlow")
  1428.     {
  1429.         optionVar 
  1430.             -intValue updateShaderGlow (!`optionVar -query updateShaderGlow`);
  1431.         if (`iprEngine -query -exists defaultIprEngine`)
  1432.         {
  1433.             iprEngine 
  1434.                 -edit 
  1435.                 -updateShaderGlow (`optionVar -query updateShaderGlow`) 
  1436.                 defaultIprEngine;
  1437.             renderWindowRefreshMenu("ipr", $editor);
  1438.         }
  1439.     }
  1440.     else if ($command == "updateMotionBlur")
  1441.     {
  1442.         optionVar 
  1443.             -intValue updateMotionBlur (!`optionVar -query updateMotionBlur`);
  1444.         if (`iprEngine -query -exists defaultIprEngine`)
  1445.         {
  1446.             iprEngine 
  1447.                 -edit 
  1448.                 -updateMotionBlur (`optionVar -query updateMotionBlur`) 
  1449.                 defaultIprEngine;
  1450.             renderWindowRefreshMenu("ipr", $editor);
  1451.         }
  1452.     }
  1453.     else if ($command == "showRegionMarquee")
  1454.     {
  1455.         string    $camera     = `getCurrentCamera`;
  1456.         string    $panel         = `getCameraPanel( $camera )`;
  1457.         int        $res[]         = `getTestResolution( $panel )`;
  1458.  
  1459.         renderWindowEditor 
  1460.             -edit
  1461.             -showRegion $res[0] $res[1]  
  1462.             $editor;
  1463.     }
  1464.     else if ($command == "dithered")
  1465.     {
  1466.         int $singleBuffer = `renderWindowEditor -query -singleBuffer $editor`;
  1467.  
  1468.         if ($singleBuffer == 0) 
  1469.         {
  1470.             renderWindowEditor 
  1471.                 -edit 
  1472.                 -singleBuffer 
  1473.                 $editor;
  1474.         } 
  1475.         else 
  1476.         {
  1477.             renderWindowEditor 
  1478.                 -edit 
  1479.                 -doubleBuffer 
  1480.                 $editor;
  1481.         }
  1482.     }
  1483.     else if ($command == "toolbar")
  1484.     {
  1485.         toggleDisplayToolbar();
  1486.         renderWindowRefreshLayout($editor);
  1487.     }
  1488.     else if ($command == "grabSwatch")
  1489.     {
  1490.         if (`renderWindowEditor -query -snapshotMode $editor`) {
  1491.             // The user is already in grab swatch mode, so we will get out of
  1492.             // grab swatch mode.
  1493.             //
  1494.             renderWindowEditor -edit -caption "" $editor;
  1495.             renderWindowEditor -edit -snapshotMode off $editor;
  1496.         } else {
  1497.             // We will enter grab swatch mode.
  1498.             //
  1499.             renderWindowEditor 
  1500.                 -edit
  1501.                 -caption "Select a region and drag it to a swatch in Hypershade"
  1502.                 $editor;
  1503.             renderWindowEditor -edit -snapshotMode on $editor;
  1504.         }
  1505.     }
  1506. }
  1507.  
  1508.  
  1509.  
  1510. //----------------------------------------------------------------------------//
  1511. // Procedures which generate menu items and procedures which refresh menus
  1512. // when they are opened
  1513. //----------------------------------------------------------------------------//
  1514.  
  1515. proc createFileMenu(string $editor, string $menuType)
  1516. {
  1517.     if ($menuType == "popup")
  1518.     {
  1519.         menuItem
  1520.             -label                     "File"
  1521.             -subMenu                true
  1522.             -postMenuCommand        
  1523.                 ("renderWindowRefreshMenu "
  1524.                     + "\"file\" "
  1525.                     + $editor)
  1526.             -familyImage            ""
  1527.             ($editor + $menuType + "FileMenu");
  1528.     }
  1529.     else
  1530.     {
  1531.         menu 
  1532.             -label                     "File"
  1533.             -tearOff                true
  1534.             -postMenuCommand        
  1535.                 ("renderWindowRefreshMenu "
  1536.                     + "\"file\" "
  1537.                     + $editor)
  1538.             -familyImage            ""
  1539.             ($editor + $menuType + "FileMenu");
  1540.     }
  1541.  
  1542.     menuItem
  1543.         -label                    "Open Image..."
  1544.         -command
  1545.             ("renderWindowMenuCommand loadImage " + $editor) 
  1546.         -annotation
  1547.             "Load an image from disk."
  1548.         ($editor + "loadImageItem");
  1549.     
  1550.     menuItem
  1551.         -label                    "Save Image..."
  1552.         -command
  1553.             ("renderWindowMenuCommand saveImage " + $editor) 
  1554.         -annotation    
  1555.             "Save the currently displayed image to disk."
  1556.         ($editor + "saveImageItem");
  1557.     
  1558.     menuItem
  1559.         -divider true;
  1560.     
  1561.     menuItem
  1562.         -label                    "Open IPR File..."
  1563.         -command
  1564.             ("renderWindowMenuCommand loadIprFile " + $editor) 
  1565.         -annotation
  1566.             "Load an IPR file from disk."
  1567.         ($editor + "loadIprFileItem");
  1568.     
  1569.     menuItem
  1570.         -label                    "Save IPR File..."
  1571.         -command
  1572.             ("renderWindowMenuCommand saveIprFile " + $editor) 
  1573.         -annotation
  1574.             "Save an IPR file to disk."
  1575.         ($editor + "saveIprFileItem");
  1576.     
  1577.     menuItem
  1578.         -label                    "Close IPR File..."
  1579.         -command
  1580.             ("renderWindowMenuCommand closeIprFile " + $editor) 
  1581.         -annotation
  1582.             "Finish your IPR session with the current IPR file."
  1583.         ($editor + "closeIprFileItem");
  1584.     
  1585.     menuItem
  1586.         -divider true;
  1587.     
  1588.     menuItem -label "Render Diagnostics..."
  1589.         -annotation (getRunTimeCommandAnnotation("RenderDiagnostics"))
  1590.         -command ("RenderDiagnostics")
  1591.         ($editor + "renderDiagnosticsItem");
  1592.     
  1593.     menuItem
  1594.         -divider true;
  1595.     
  1596.     menuItem
  1597.         -label                    "Keep Image in Render View"
  1598.         -command
  1599.             ("renderWindowMenuCommand keepImageInRenderView " + $editor) 
  1600.         -annotation
  1601.             "Temporarily save the currently displayed image in Maya's image buffer."
  1602.         ($editor + "keepImageInRenderViewItem");
  1603.     
  1604.     menuItem
  1605.         -label                    "Remove Image from Render View"
  1606.         -command                
  1607.             ("renderWindowMenuCommand removeImageFromRenderView " + $editor) 
  1608.         -annotation
  1609.             "Remove the currently displayed image from Maya's image buffer."
  1610.         ($editor + "removeImageFromRenderViewItem");
  1611.  
  1612.     setParent -menu ..; // from FileMenu
  1613. }
  1614.  
  1615. proc refreshFileMenu(string $editor, string $menuType)
  1616. {
  1617.     setParent -menu ($editor + $menuType + "FileMenu");
  1618.  
  1619.     // If there is no image or IPR image currently in the renderview, dim the 
  1620.     // Save Image... item, the Keep Image in Render View item and the Remove 
  1621.     // Image from Render View item.
  1622.     //
  1623.     if (isImageLoaded($editor))
  1624.     {
  1625.         menuItem
  1626.             -edit
  1627.             -enable                true
  1628.             ($editor + "saveImageItem");
  1629.         menuItem
  1630.             -edit
  1631.             -enable                true
  1632.             ($editor + "keepImageInRenderViewItem");
  1633.     }
  1634.     else
  1635.     {
  1636.         menuItem
  1637.             -edit
  1638.             -enable                false
  1639.             ($editor + "saveImageItem");
  1640.         menuItem
  1641.             -edit
  1642.             -enable                false
  1643.             ($editor + "keepImageInRenderViewItem");
  1644.     }
  1645.  
  1646.     // If current renderer supports IPR
  1647.     //
  1648.     string $currentRendererName = currentRenderer(); 
  1649.     if (`renderer -query -iprRenderProcedure $currentRendererName` != "")
  1650.     {
  1651.         // Enable load ipr file menuitem if ipr is supported
  1652.         //
  1653.         menuItem
  1654.             -edit
  1655.             -enable                true
  1656.             ($editor + "loadIprFileItem");
  1657.  
  1658.         // If there is no IPR file currently in the renderview, dim the Save IPR
  1659.         // File... item.
  1660.         //
  1661.         if (isIprFileLoaded())
  1662.         {
  1663.             menuItem
  1664.                 -edit
  1665.                 -enable                true
  1666.                 ($editor + "saveIprFileItem");
  1667.  
  1668.             menuItem
  1669.                 -edit
  1670.                 -enable                true
  1671.                 ($editor + "closeIprFileItem");
  1672.         }
  1673.         else
  1674.         {
  1675.             menuItem
  1676.                 -edit
  1677.                 -enable                false
  1678.                 ($editor + "saveIprFileItem");
  1679.  
  1680.             menuItem
  1681.                 -edit
  1682.                 -enable                false
  1683.                 ($editor + "closeIprFileItem");
  1684.         }
  1685.     }
  1686.     else
  1687.     {
  1688.         menuItem
  1689.             -edit
  1690.             -enable                false
  1691.             ($editor + "loadIprFileItem");
  1692.  
  1693.  
  1694.         menuItem
  1695.             -edit
  1696.             -enable                false
  1697.             ($editor + "saveIprFileItem");
  1698.  
  1699.         menuItem
  1700.             -edit
  1701.             -enable                false
  1702.             ($editor + "closeIprFileItem");
  1703.     
  1704.     }
  1705.  
  1706.     
  1707.     // If current renderer supports renderdiagnostics, disable/enable
  1708.     //    related UI
  1709.     //
  1710.     string $currentRendererName = currentRenderer(); 
  1711.     if (`renderer -query -renderDiagnosticsProcedure $currentRendererName` != "")
  1712.     {
  1713.         menuItem
  1714.             -edit
  1715.             -enable                true
  1716.             ($editor + "renderDiagnosticsItem");
  1717.     }
  1718.     else
  1719.     {
  1720.         menuItem
  1721.             -edit
  1722.             -enable                false
  1723.             ($editor + "renderDiagnosticsItem");
  1724.     }
  1725.     // If the renderview is currently looking at the non-buffered image, dim
  1726.     // the Remove Image from Render View item.
  1727.     //
  1728.     if (`renderWindowEditor -query -displayImage $editor` >= 0)
  1729.     {
  1730.         menuItem
  1731.             -edit
  1732.             -enable                true
  1733.             ($editor + "removeImageFromRenderViewItem");
  1734.     }
  1735.     else
  1736.     {
  1737.         menuItem
  1738.             -edit
  1739.             -enable                false
  1740.             ($editor + "removeImageFromRenderViewItem");
  1741.     }
  1742. }
  1743.  
  1744. proc createRenderMenu(string $editor, string $menuType)
  1745. {
  1746.     // Create the Render menu
  1747.     //
  1748.     if ($menuType == "popup")
  1749.     {
  1750.         menuItem
  1751.             -subMenu                true
  1752.             -label                     "Render"
  1753.             -postMenuCommand        
  1754.                 ("renderWindowRefreshMenu "
  1755.                     + "\"render\" "
  1756.                     + $editor)
  1757.             -familyImage            "menuIconRender.xpm"
  1758.             ($editor + $menuType + "RenderMenu");
  1759.     }
  1760.     else
  1761.     {
  1762.         menu 
  1763.             -label                     "Render"
  1764.             -tearOff                 true
  1765.             -postMenuCommand        
  1766.                 ("renderWindowRefreshMenu "
  1767.                     + "\"render\" "
  1768.                     + $editor)
  1769.             -familyImage            "menuIconRender.xpm"
  1770.             ($editor + $menuType + "RenderMenu");
  1771.     }
  1772.  
  1773.     menuItem
  1774.         -label                    "Redo Previous Render"
  1775.         -command                
  1776.             ("renderWindowRender redoPreviousRender " + $editor)
  1777.         -annotation
  1778.             "Render using the camera used to do the previous render."
  1779.         ($editor + "redoPreviousRenderItem");
  1780.  
  1781.     menuItem
  1782.         -label                    "Render Region"
  1783.         -command                
  1784.             ("renderWindowRenderRegion " + $editor)
  1785.         -annotation
  1786.             "Render the part of the image contained within the region marquee."
  1787.         ($editor + "renderRegionItem");
  1788.  
  1789.     menuItem
  1790.         -divider true;
  1791.     
  1792.     //
  1793.     //    Dynamic render menu, it contains the list of cameras to render
  1794.     //    from.
  1795.     //
  1796.     menuItem
  1797.         -label                     "Render" 
  1798.         -subMenu                 true 
  1799.         -tearOff                 true
  1800.         ($editor + $menuType + "renderRenderItem");
  1801.     menuItem 
  1802.         -edit 
  1803.         -postMenuCommand 
  1804.             ("renderWindowCreateCameraSubmenu "
  1805.                 + $editor 
  1806.                 + $menuType 
  1807.                 + "renderRenderItem"
  1808.                 + " "
  1809.                 + "\"renderWindowRenderCamera render "
  1810.                 + $editor
  1811.                 + " \""
  1812.                 + $editor)
  1813.         -annotation
  1814.             "Render using a particular camera."
  1815.         ($editor + $menuType + "renderRenderItem");
  1816.     setParent -menu ..; // from Render menu
  1817.  
  1818.     //
  1819.     //    Dynamic snapshot render menu, it contains the list of visible
  1820.     //    camera panels to render from.
  1821.     //
  1822.     menuItem 
  1823.         -label                     "Snapshot" 
  1824.         -subMenu                 true 
  1825.         -tearOff                 true
  1826.         ($editor + $menuType + "renderSnapshotItem");
  1827.     menuItem 
  1828.         -edit 
  1829.         -postMenuCommand 
  1830.             ("renderWindowCreateCameraSubmenu "
  1831.                 + $editor
  1832.                 + $menuType 
  1833.                 + "renderSnapshotItem"
  1834.                 + " "
  1835.                 + "\"renderWindowRenderCamera snapshot "
  1836.                 + $editor
  1837.                 + " \""
  1838.                 + $editor)
  1839.         -annotation
  1840.             "Take a wireframe snapshot using a particular camera."
  1841.         ($editor + $menuType + "renderSnapshotItem");
  1842.     setParent -menu ..; // from Snapshot menu
  1843.     
  1844.     setParent -menu ..; // from Render menu
  1845. }
  1846.  
  1847. proc refreshRenderMenu(string $editor, string $menuType)
  1848. {
  1849.     setParent -menu ($editor + $menuType + "RenderMenu");
  1850. }
  1851.  
  1852. proc createIprMenu(string $editor, string $menuType)
  1853. {
  1854.     // Create the IPR menu
  1855.     //
  1856.     if ($menuType == "popup")
  1857.     {
  1858.         menuItem
  1859.             -subMenu                true
  1860.             -label                     "IPR"
  1861.             -postMenuCommand        
  1862.                 ("renderWindowRefreshMenu "
  1863.                     + "\"ipr\" "
  1864.                     + $editor)
  1865.             -familyImage            ""
  1866.             ($editor + $menuType + "IprMenu");
  1867.     }
  1868.     else
  1869.     {
  1870.         menu 
  1871.             -label                     "IPR"
  1872.             -tearOff                 true
  1873.             -postMenuCommand        
  1874.                 ("renderWindowRefreshMenu "
  1875.                     + "\"ipr\" "
  1876.                     + $editor)
  1877.             -familyImage            ""
  1878.             ($editor + $menuType + "IprMenu");
  1879.     }
  1880.  
  1881.     menuItem
  1882.         -label                    "Redo Previous IPR Render"
  1883.         -command                
  1884.             ("renderWindowRender redoPreviousIprRender " + $editor)
  1885.         -annotation
  1886.             "IPR Render using the camera used to do the previous render."
  1887.         ($editor + "redoPreviousIprRenderItem");
  1888.  
  1889.     menuItem
  1890.         -divider true;
  1891.     
  1892.     //
  1893.     //    Dynamic render menu, it contains the list of cameras to render
  1894.     //    from.
  1895.     //
  1896.     menuItem
  1897.         -label                     "IPR Render" 
  1898.         -subMenu                 true 
  1899.         -tearOff                 true
  1900.         ($editor + $menuType + "iprRenderItem");
  1901.     menuItem 
  1902.         -edit 
  1903.         -postMenuCommand 
  1904.             ("renderWindowCreateCameraSubmenu "
  1905.                 + $editor 
  1906.                 + $menuType
  1907.                 + "iprRenderItem "
  1908.                 + "\"renderWindowRenderCamera iprRender "
  1909.                 + $editor
  1910.                 + " \""
  1911.                 + $editor)
  1912.         -annotation
  1913.             "Render using a particular camera."
  1914.         ($editor + $menuType + "iprRenderItem");
  1915.     setParent -menu ..; // from Render menu
  1916.  
  1917.     menuItem
  1918.         -divider true;
  1919.     
  1920.     menuItem
  1921.         -label                     "Update Shadow Maps"
  1922.         -command                
  1923.             ("renderWindowMenuCommand updateShadowMaps " + $editor)
  1924.         -annotation
  1925.             ("Re-create shadow maps for specific lights. "
  1926.                 + "(Required after lights change position etc.)")
  1927.         ($editor + "updateShadowMapsItem");
  1928.  
  1929.     menuItem
  1930.         -label                    "Update Image Planes/Background"
  1931.         -command
  1932.             ("renderWindowMenuCommand loadSamples " + $editor)
  1933.         -annotation
  1934.             ("Re-load IPR pixels in the marquee region. Required after "+
  1935.              "adjusting image planes.")
  1936.         ($editor + "loadSamplesItem");
  1937.  
  1938.     menuItem
  1939.         -label                    "Refresh IPR Image"
  1940.         -command
  1941.             ("renderWindowMenuCommand refreshIprImage " + $editor)
  1942.         -annotation
  1943.             ("Refresh the ipr image tile-by-tile.")
  1944.         ($editor + "refreshIprImage");
  1945.  
  1946.     menuItem 
  1947.         -label                    "IPR Tuning Options"
  1948.         -subMenu                true
  1949.         -tearOff                 true
  1950.         ($editor + "iprUpdateOptionsItem");
  1951.  
  1952.         menuItem
  1953.             -enable                false
  1954.             -label                "Update Shading and Lighting"
  1955.             -checkBox            true
  1956.             -annotation
  1957.                 ("When checked, changes to shading or lighting parameters "+
  1958.                  "will be shown in the interactive IPR render.")
  1959.             -command            
  1960.                 ("renderWindowMenuCommand updateShadingAndLighting " + $editor)
  1961.             ($editor + "updateShadingAndLightingItem");
  1962.  
  1963.         menuItem
  1964.             -label                "Update Shader Glow"
  1965.             -checkBox            true
  1966.             -annotation
  1967.                 ("When checked, changes to shader glow parameters "+
  1968.                  "will be shown in the interactive IPR render.")
  1969.             -command            
  1970.                 ("renderWindowMenuCommand updateShaderGlow " + $editor)
  1971.             ($editor + "updateShaderGlowItem");
  1972.  
  1973.         menuItem
  1974.             -label                "Update Light Glow"
  1975.             -checkBox            true
  1976.             -annotation
  1977.                 ("When checked, changes to light glow parameters "+
  1978.                  "will be shown in the interactive IPR render.")
  1979.             -command            
  1980.                 ("renderWindowMenuCommand updateLightGlow " + $editor)
  1981.             ($editor + "updateLightGlowItem");
  1982.  
  1983.         menuItem
  1984.             -label              "Update 2D Motion Blur"
  1985.             -checkBox           true
  1986.             -annotation
  1987.                 ("When checked, changes to 2D motion blur parameters "+
  1988.                  "will be shown in the interactive IPR render.")
  1989.             -command                
  1990.                 ("renderWindowMenuCommand updateMotionBlur " + $editor)
  1991.             ($editor + "updateMotionBlurItem");
  1992.  
  1993.     setParent -menu ..; // from IPR Tuning Options
  1994.  
  1995.     menuItem
  1996.         -divider true;
  1997.  
  1998.     global int $gIprTuningPaused;
  1999.  
  2000.     menuItem
  2001.         -label                    "Pause IPR Tuning"
  2002.         -checkBox                $gIprTuningPaused
  2003.         -command
  2004.             ("renderWindowMenuCommand togglePauseTuning " + $editor)
  2005.         -annotation
  2006.             ("Pause/unpause IPR tuning.")
  2007.         ($editor + "pauseIprTuning");
  2008.  
  2009.     setParent -menu ..; // from IPR menu
  2010. }
  2011.  
  2012. proc refreshIprMenu(string $editor, string $menuType)
  2013. {
  2014.     setParent -menu ($editor + $menuType + "IprMenu");
  2015.  
  2016.     global int $gIprTuningPaused;
  2017.  
  2018.     string $currentRendererName = currentRenderer(); 
  2019.     if (`renderer -query -iprRenderProcedure $currentRendererName` != "") 
  2020.     {
  2021.  
  2022.         string $iprMenuItems[] = `menu -query -itemArray ($editor + $menuType + "IprMenu")`;
  2023.         //
  2024.         // Enable ipr menuItems if renderer supports the ipr feature.
  2025.         // These items have to be explicitly enabled in case they were
  2026.         // disabled by the previous renderer
  2027.         //
  2028.         for ($i = 0; $i < size($iprMenuItems); $i += 1)
  2029.         {
  2030.             menuItem -edit -enable true $iprMenuItems[$i];
  2031.         }
  2032.  
  2033.         if (isIprFileLoaded())
  2034.         {
  2035.             menuItem
  2036.                 -edit
  2037.                 -enable                    true
  2038.                 ($editor + "updateShadowMapsItem");
  2039.  
  2040.             menuItem
  2041.                 -edit
  2042.                 -enable                    true
  2043.                 ($editor + "loadSamplesItem");
  2044.  
  2045.             menuItem
  2046.                 -edit
  2047.                 -enable                    (!$gIprTuningPaused)
  2048.                 ($editor + "refreshIprImage");
  2049.  
  2050.             menuItem
  2051.                 -edit
  2052.                 -enable                    true
  2053.                 ($editor + "iprUpdateOptionsItem");
  2054.  
  2055.             menuItem
  2056.                 -edit
  2057.                 -enable                    true
  2058.                 ($editor + "pauseIprTuning");
  2059.         }
  2060.         else
  2061.         {
  2062.             menuItem
  2063.                 -edit
  2064.                 -enable                    false
  2065.                 ($editor + "updateShadowMapsItem");
  2066.  
  2067.             menuItem
  2068.                 -edit
  2069.                 -enable                    false
  2070.                 ($editor + "loadSamplesItem");
  2071.  
  2072.             menuItem
  2073.                 -edit
  2074.                 -enable                    false
  2075.                 ($editor + "refreshIprImage");
  2076.  
  2077.             menuItem
  2078.                 -edit
  2079.                 -enable                    false
  2080.                 ($editor + "iprUpdateOptionsItem");
  2081.  
  2082.             menuItem
  2083.                 -edit
  2084.                 -enable                    false
  2085.                 ($editor + "pauseIprTuning");
  2086.         }
  2087.  
  2088.         // Check or uncheck the "Pause IPR Tuning" menu item checkbox 
  2089.         // appropriately
  2090.         //
  2091.         menuItem
  2092.             -edit
  2093.             -checkBox                $gIprTuningPaused
  2094.             ($editor + "pauseIprTuning");
  2095.  
  2096.         if (isIprFileLoaded())
  2097.         {
  2098.             // Only allow the user to modify settings which will have an effect.
  2099.             // If, for example, the currently loaded IPR file does not contain
  2100.             // samples needed for shading and lighting tuning, then disable the
  2101.             // shading and lighting option.
  2102.             //
  2103.             int $shadingAndLightingAvailable        = true;
  2104.             int $lightGlowAvailable        = isIprFileLoaded();
  2105.             int $shaderGlowAvailable    = isIprFileLoaded();
  2106.  
  2107.         int $motionBlurAvailable = false;
  2108.         string $motionVectorFile[] = `iprEngine -q -motionVectorFile defaultIprEngine`;
  2109.         if (size($motionVectorFile) > 0)
  2110.             if ($motionVectorFile[0] != "")                
  2111.                 $motionBlurAvailable    = true;
  2112.  
  2113.         menuItem
  2114.             -edit
  2115.             -checkBox        ($shadingAndLightingAvailable && `optionVar -query updateShadingAndLighting`)
  2116.             -enable            $shadingAndLightingAvailable
  2117.             ($editor + "updateShadingAndLightingItem");
  2118.  
  2119.         menuItem
  2120.             -edit
  2121.             -checkBox        ($lightGlowAvailable && `optionVar -query updateLightGlow`)
  2122.             -enable            $lightGlowAvailable
  2123.             ($editor + "updateLightGlowItem");
  2124.  
  2125.         menuItem
  2126.             -edit
  2127.             -checkBox        ($shaderGlowAvailable && `optionVar -query updateShaderGlow`)
  2128.             -enable            $shaderGlowAvailable
  2129.             ($editor + "updateShaderGlowItem");
  2130.  
  2131.         menuItem
  2132.             -edit
  2133.             -checkBox        ($motionBlurAvailable && `optionVar -query updateMotionBlur`)
  2134.             -enable            $motionBlurAvailable
  2135.             ($editor + "updateMotionBlurItem");
  2136.         }
  2137.     }
  2138.     else
  2139.     {
  2140.         string $iprMenuItems[] = `menu -query -itemArray ($editor + $menuType + "IprMenu")`;
  2141.  
  2142.         // Disable all ipr menuItems if current renderer does not support ipr.
  2143.         // Since the menu itself cannot be disabled, all menuItems are being 
  2144.         // greyed out
  2145.         //
  2146.         for ($i = 0; $i < size($iprMenuItems); $i += 1)
  2147.         {
  2148.             menuItem -edit -enable false $iprMenuItems[$i];
  2149.         }
  2150.     }
  2151. }
  2152.  
  2153.  
  2154. proc createOptionsMenu(string $editor, string $menuType)
  2155. {
  2156.     string $subName;
  2157.  
  2158.     if ($menuType == "popup")
  2159.     {
  2160.         menuItem
  2161.             -subMenu                true
  2162.             -label                     "Options"
  2163.             -postMenuCommand        
  2164.                 ("renderWindowRefreshMenu "
  2165.                     + "\"options\" "
  2166.                     + $editor)
  2167.             -familyImage             "menuIconRenderSettings.xpm"
  2168.             ($editor + $menuType + "OptionsMenu");
  2169.     }
  2170.     else
  2171.     {
  2172.         menu 
  2173.             -label                     "Options"
  2174.             -tearOff                true
  2175.             -postMenuCommand        
  2176.                 ("renderWindowRefreshMenu "
  2177.                     + "\"options\" "
  2178.                     + $editor)
  2179.             -familyImage             "menuIconRenderSettings.xpm"
  2180.             ($editor + $menuType + "OptionsMenu");
  2181.     }
  2182.  
  2183.     setParent -menu ..; // from Options menu
  2184. }
  2185.  
  2186. proc buildOptionsMenu(string $editor, string $menuType)
  2187. {
  2188.     // Create a render globals menu item for each available renderer
  2189.     //
  2190.     int $i;
  2191.     string $rendererUIName = "";
  2192.     string $command = "displayRenderGlobalsWindow"; 
  2193.  
  2194.     if ($command != "")
  2195.     {
  2196.         menuItem 
  2197.             -enableCommandRepeat false 
  2198.             -label "Render Globals ..." 
  2199.             -annotation "Render Globals: Change global rendering attributes"
  2200.             -command $command;
  2201.     }
  2202.  
  2203.     menuItem
  2204.         -subMenu                true
  2205.         -label                    "Render using"
  2206.         -annotation
  2207.             "Change current renderer"
  2208.         ($editor + $menuType + "renderUsingItem");
  2209.  
  2210.     menuItem
  2211.         -edit
  2212.         -postMenuCommand
  2213.             ("buildRenderUsingMenu "
  2214.                 + $editor
  2215.                 + $menuType + "renderUsingItem "
  2216.                 + $editor)
  2217.         ($editor + $menuType + "renderUsingItem");
  2218.  
  2219.     setParent -menu ..;
  2220.  
  2221.     menuItem -divider true;
  2222.  
  2223.  
  2224.     menuItem
  2225.         -subMenu                true
  2226.         -label                    "Test Resolution"
  2227.         -annotation
  2228.             "Change the resolution of test renders."
  2229.         ($editor + $menuType + "resolutionItem");
  2230.  
  2231.     menuItem
  2232.         -edit
  2233.         -postMenuCommand 
  2234.             ("renderWindowMakeResolutionItem "
  2235.                 + $editor
  2236.                 + $menuType + "resolutionItem "
  2237.                 + $editor)
  2238.         ($editor + $menuType + "resolutionItem");
  2239.  
  2240.     setParent -menu ..; // from Resolution menu
  2241.     
  2242.     menuItem -divider true;
  2243.  
  2244.     menuItem
  2245.         -label                    "Auto Resize"
  2246.         -checkBox                false
  2247.         -command                ("switchAutoResizeVar " + $editor)
  2248.         -annotation
  2249.             ("When checked, each new test render will automatically be resized "
  2250.                 + "to real size and centered on the screen.")
  2251.         ($editor + "autoResizeItem");
  2252.     
  2253.     menuItem
  2254.         -label                    "Auto Render Region"
  2255.         -checkBox                false
  2256.         -command                "switchAutoRenderRegionVar"
  2257.         -annotation
  2258.             ("When checked, a Render Region will automatically begin as soon "
  2259.                 + "as you finish marqueeing a region.")
  2260.         ($editor + "autoRenderRegionItem");
  2261.  
  2262.  
  2263.     menuItem -divider true;
  2264.  
  2265.     menuItem
  2266.         -label                  "Ignore Shadows"
  2267.         -checkBox               false
  2268.         -command                ("switchShadowsVar " + $editor)
  2269.         -annotation
  2270.             ("When checked, no shadows will be rendered")
  2271.         ($editor + "shadowsItem");
  2272.  
  2273.     menuItem
  2274.         -label                  "Ignore Glows"
  2275.         -checkBox               false
  2276.         -command                ("switchGlowPassVar " + $editor)
  2277.         -annotation
  2278.             ("When checked, no glow pass will be rendered")
  2279.         ($editor + "glowPassItem");
  2280. }
  2281.  
  2282. proc refreshOptionsMenu(string $editor, string $menuType)
  2283. {
  2284.     global int $renderViewShadowsMode;
  2285.     global int $renderViewGlowPassMode;
  2286.  
  2287.     setParent -menu ($editor + $menuType + "OptionsMenu");
  2288.  
  2289.     menu
  2290.         -edit
  2291.         -deleteAllItems 
  2292.         ($editor + $menuType + "OptionsMenu");
  2293.     
  2294.     buildOptionsMenu($editor, $menuType);
  2295.  
  2296.     // If auto resize is on, check the Auto Resize checkbox.
  2297.     //
  2298.     menuItem
  2299.         -edit
  2300.         -checkBox            `optionVar -query renderViewAutoResize`
  2301.         ($editor + "autoResizeItem");
  2302.  
  2303.     menuItem
  2304.         -edit
  2305.         -checkBox            $renderViewShadowsMode
  2306.         ($editor + "shadowsItem");
  2307.  
  2308.     menuItem
  2309.         -edit
  2310.         -checkBox           $renderViewGlowPassMode
  2311.         ($editor + "glowPassItem");
  2312.  
  2313.     // Make sure the state of the renderWindowEditor accurately reflects the
  2314.     // user's setting of the optionVar
  2315.     //
  2316.     renderWindowEditor
  2317.         -edit
  2318.         -autoResize            `optionVar -query renderViewAutoResize`
  2319.         $editor;
  2320.  
  2321.     // If auto render region is on, check the Auto Render Region checkbox.
  2322.     //
  2323.     menuItem
  2324.         -edit
  2325.         -enable            true
  2326.         -checkBox            `optionVar -query renderViewAutoRenderRegion`
  2327.         ($editor + "autoRenderRegionItem");
  2328.  
  2329.     string $currentRendererName = currentRenderer(); 
  2330.     if (`renderer -query -iprRenderProcedure $currentRendererName` != "") 
  2331.     {
  2332.         // Disable this menu item for IPR
  2333.         if (isIprFileLoaded()) {
  2334.             menuItem -edit -enable false    
  2335.                 ($editor + "autoRenderRegionItem");
  2336.         }
  2337.  
  2338.         // Disable these menu items for IPR
  2339.         if (isIprFileLoaded()) {
  2340.             menuItem -edit -enable false ($editor + "shadowsItem");
  2341.             menuItem -edit -enable false ($editor + "glowPassItem");
  2342.         } else {
  2343.             menuItem -edit -enable true ($editor + "shadowsItem");
  2344.             menuItem -edit -enable true ($editor + "glowPassItem");
  2345.         }
  2346.     }
  2347.     else
  2348.     {
  2349.         menuItem -edit -enable false ($editor + "shadowsItem");
  2350.         menuItem -edit -enable false ($editor + "glowPassItem");
  2351.     }
  2352. }
  2353.  
  2354. proc createViewMenu(string $editor, string $menuType)
  2355. {
  2356.     if ($menuType == "popup")
  2357.     {
  2358.         menuItem
  2359.             -subMenu                true
  2360.             -label                     "View"
  2361.             -postMenuCommand        
  2362.                 ("renderWindowRefreshMenu "
  2363.                     + "\"view\" "
  2364.                     + $editor)
  2365.             -familyImage             "menuIconView.xpm"
  2366.             ($editor + $menuType + "ViewMenu");
  2367.     }
  2368.     else
  2369.     {
  2370.         menu 
  2371.             -label                     "View"
  2372.             -tearOff                true
  2373.             -postMenuCommand        
  2374.                 ("renderWindowRefreshMenu "
  2375.                     + "\"view\" "
  2376.                     + $editor)
  2377.             -familyImage             "menuIconView.xpm"
  2378.             ($editor + $menuType + "ViewMenu");
  2379.     }
  2380.  
  2381.     menuItem
  2382.         -label                    "Frame Image"
  2383.         -command                
  2384.             ("renderWindowEditor "
  2385.                 + "-edit "
  2386.                 + "-frameImage "
  2387.                 + $editor)
  2388.         -annotation
  2389.             "Zoom the image so it just fits in the render view."
  2390.         ($editor + "frameImageItem");
  2391.     
  2392.     menuItem
  2393.         -label                    "Frame Region"
  2394.         -command
  2395.             ("renderWindowEditor "
  2396.                 + "-edit "
  2397.                 + "-frameRegion "
  2398.                 + $editor)
  2399.         -annotation
  2400.             "Zoom the region so it just fits in the render view."
  2401.         ($editor + "frameRegionItem");
  2402.     
  2403.     menuItem
  2404.         -label                    "Real Size"
  2405.         -command
  2406.             ("renderWindowEditor "
  2407.                 + "-edit "
  2408.                 + "-realSize "
  2409.                 + $editor)
  2410.         -annotation
  2411.             "Zoom the image so it is displayed at its real size."
  2412.         ($editor + "realSizeItem");
  2413.     
  2414.     menuItem -divider true;
  2415.  
  2416.     menuItem
  2417.         -label                    "Show Region Marquee"
  2418.         -command ("renderWindowMenuCommand showRegionMarquee " + $editor)
  2419.         -annotation
  2420.             "Show the region marquee."
  2421.         ($editor + "showRegionMarqueeItem");
  2422.     
  2423.     menuItem
  2424.         -label                    "Reset Region Marquee"
  2425.         -command                
  2426.             ("renderWindowEditor "
  2427.                 + "-edit "
  2428.                 + "-marquee 1.0 0.0 0.0 1.0 "
  2429.                 + $editor)
  2430.         -annotation
  2431.             "Reset the region to be the size of the entire image."
  2432.         ($editor + "resetRegionMarqueeItem");
  2433.  
  2434.     menuItem -divider true;
  2435.  
  2436.     menuItem
  2437.         -label        "Grab Swatch to Hypershade/Visor"
  2438.         -command ("renderWindowMenuCommand grabSwatch " + $editor)
  2439.         -annotation "Grab Swatch to Hypershade/Visor"
  2440.         ($editor + "grabSwatchItem");
  2441.     
  2442.     setParent -menu ..; // from View menu
  2443. }
  2444.  
  2445. proc refreshViewMenu(string $editor, string $menuType)
  2446. {
  2447.     //
  2448.     // Set the appropriate text for the grab swatch
  2449.     //
  2450.     if ($menuType == "menubar") {
  2451.         setParent -menu ($editor + $menuType + "ViewMenu");
  2452.     } else if ($menuType == "popup") {
  2453.         setParent -menu ($editor + $menuType + "OptionsMenu");
  2454.     }
  2455.     if (`renderWindowEditor -query -snapshotMode $editor`) {
  2456.         menuItem -edit
  2457.             -label        "Cancel Swatch Grab to Hypershade/Visor"
  2458.             -annotation "Cancel Swatch Grab to Hypershade/Visor"
  2459.             ($editor + "grabSwatchItem");
  2460.     } else {
  2461.         menuItem -edit
  2462.             -label        "Grab Swatch to Hypershade/Visor"
  2463.             -annotation "Grab Swatch to Hypershade/Visor"
  2464.             ($editor + "grabSwatchItem");
  2465.     }
  2466. }
  2467.  
  2468. proc refreshDisplayMenu(string $editor, string $menuType)
  2469. {
  2470.     setParent -menu ($editor + $menuType + "DisplayMenu");
  2471.  
  2472.     // Check the display style and color channel information. 
  2473.     //
  2474.     string $displayStyle = `renderWindowEditor -q -displayStyle $editor`;
  2475.     float  $scaleRed = `renderWindowEditor -q -scaleRed $editor`;
  2476.     float  $scaleGreen = `renderWindowEditor -q -scaleGreen $editor`;
  2477.     float  $scaleBlue = `renderWindowEditor -q -scaleBlue $editor`;
  2478.     int $isColor = ($displayStyle == "color");
  2479.     int $isRed = $isColor && ($scaleRed == 1.0);
  2480.     int $isGreen = $isColor && ($scaleGreen == 1.0);
  2481.     int $isBlue = $isColor && ($scaleBlue == 1.0);
  2482.  
  2483.     // Update the display style and color channel radioButton menuItems.
  2484.     //
  2485.     menuItem -edit 
  2486.         -radioButton            ($isRed && !$isBlue && !$isGreen)
  2487.         ($editor + "redPlaneItem");
  2488.  
  2489.     menuItem -edit
  2490.         -radioButton            (!$isRed && !$isBlue && $isGreen)
  2491.         ($editor + "greenPlaneItem");
  2492.  
  2493.     menuItem -edit
  2494.         -radioButton            (!$isRed && $isBlue && !$isGreen)
  2495.         ($editor + "bluePlaneItem");
  2496.  
  2497.     menuItem -edit
  2498.         -radioButton            ($isColor && $isRed && $isGreen && $isBlue )
  2499.         ($editor + "allPlanesItem");
  2500.  
  2501.     menuItem -edit
  2502.         -radioButton            (!$isColor && ($displayStyle == "lum"))
  2503.         ($editor + "luminanceItem");
  2504.  
  2505.     menuItem -edit
  2506.         -radioButton            (!$isColor && ($displayStyle == "mask"))
  2507.         ($editor + "maskPlaneItem");
  2508.  
  2509.     // Update the dithered menuItem
  2510.     //
  2511.     int $dithered = !`renderWindowEditor -query -singleBuffer $editor`;
  2512.     menuItem -edit -checkBox $dithered ($editor + "ditheredItem");
  2513.  
  2514.     // Update the toolbar menuItem
  2515.     //
  2516.     if (isToolbarDisplayed())
  2517.     {
  2518.         menuItem
  2519.             -edit
  2520.             -checkBox            true
  2521.             ($editor + "toolbarItem");
  2522.     }
  2523.     else
  2524.     {
  2525.         menuItem
  2526.             -edit
  2527.             -checkBox            false
  2528.             ($editor + "toolbarItem");
  2529.     }
  2530. }
  2531.  
  2532.  
  2533. // Description:  This procedure is called to create both the
  2534. //      "Display" pulldown menu in render view window and the
  2535. //      right mouse button click tear off window --> "Display"
  2536. //      meanu.
  2537. //
  2538. proc createDisplayMenu(string $editor, string $menuType)
  2539. {
  2540.     if ($menuType == "popup")
  2541.     {
  2542.         menuItem
  2543.             -subMenu                true
  2544.             -label                     "Display"
  2545.             -postMenuCommand        
  2546.                 ("renderWindowRefreshMenu "
  2547.                     + "\"display\" "
  2548.                     + $editor)
  2549.             -familyImage             "menuIconDisplay.xpm"
  2550.             ($editor + $menuType + "DisplayMenu");
  2551.     }
  2552.     else
  2553.     {
  2554.         menu 
  2555.             -label                     "Display"
  2556.             -tearOff                true
  2557.             -postMenuCommand        
  2558.                 ("renderWindowRefreshMenu "
  2559.                     + "\"display\" "
  2560.                     + $editor)
  2561.             -familyImage             "menuIconDisplay.xpm"
  2562.             ($editor + $menuType + "DisplayMenu");
  2563.     }
  2564.  
  2565.     radioMenuItemCollection    ("renderWindowPlanesCollection" + $menuType);
  2566.  
  2567.     menuItem 
  2568.         -label                     "Red Channel" 
  2569.         -radioButton             false
  2570.         -collection                ("renderWindowPlanesCollection" + $menuType)
  2571.         -command                 
  2572.             ("renderWindowEditor "
  2573.                 + "-edit "
  2574.                 + "-displayStyle \"color\" "
  2575.                 + "-scaleRed 1 "
  2576.                 + "-scaleGreen -1000 "
  2577.                 + "-scaleBlue -1000 " 
  2578.                 + $editor )
  2579.         -annotation
  2580.             "Display the red channel only."
  2581.         ($editor + "redPlaneItem");
  2582.  
  2583.     menuItem 
  2584.         -label                     "Green Channel" 
  2585.         -radioButton             false
  2586.         -collection                ("renderWindowPlanesCollection" + $menuType)
  2587.         -command                 
  2588.             ("renderWindowEditor "
  2589.                 + "-edit "
  2590.                 + "-displayStyle \"color\" "
  2591.                 + "-scaleRed -1000 "
  2592.                 + "-scaleGreen 1 "
  2593.                 + "-scaleBlue -1000 " 
  2594.                 + $editor )
  2595.         -annotation
  2596.             "Display the green channel only."
  2597.         ($editor + "greenPlaneItem");
  2598.  
  2599.     menuItem 
  2600.         -label                     "Blue Channel" 
  2601.         -radioButton             false
  2602.         -collection                ("renderWindowPlanesCollection" + $menuType)
  2603.         -command                 
  2604.             ("renderWindowEditor "
  2605.                 + "-edit "
  2606.                 + "-displayStyle \"color\" "
  2607.                 + "-scaleRed -1000 "
  2608.                 + "-scaleGreen -1000 "
  2609.                 + "-scaleBlue 1 " 
  2610.                 + $editor )
  2611.         -annotation
  2612.             "Display the blue channel only."
  2613.         ($editor + "bluePlaneItem");
  2614.  
  2615.     menuItem 
  2616.         -label                     "All Channels" 
  2617.         -radioButton             true
  2618.         -collection                ("renderWindowPlanesCollection" + $menuType)
  2619.         -command                 
  2620.             ("renderWindowEditor "
  2621.                 + "-edit "
  2622.                 + "-displayStyle \"color\" "
  2623.                 + "-scaleRed 1 "
  2624.                 + "-scaleGreen 1 "
  2625.                 + "-scaleBlue 1 " 
  2626.                 + $editor )
  2627.         -annotation
  2628.             "Display the red, green and blue channels of the image together."
  2629.         ($editor + "allPlanesItem");
  2630.  
  2631.     menuItem -divider true;
  2632.  
  2633.     menuItem 
  2634.         -label                     "Luminance" 
  2635.         -radioButton             false
  2636.         -collection                ("renderWindowPlanesCollection" + $menuType)
  2637.         -command                 
  2638.             ("renderWindowEditor "
  2639.                 + "-edit "
  2640.                 + "-displayStyle \"lum\" " 
  2641.                 + $editor )
  2642.         -annotation
  2643.             "Display the luminance of the image."
  2644.         ($editor + "luminanceItem");
  2645.  
  2646.     menuItem 
  2647.         -label                     "Alpha Channel" 
  2648.         -radioButton             false
  2649.         -collection                ("renderWindowPlanesCollection" + $menuType)
  2650.         -command                 
  2651.             ("renderWindowEditor "
  2652.                 + "-edit "
  2653.                 + "-displayStyle \"mask\" " 
  2654.                 + $editor )
  2655.         -annotation
  2656.             "Display the alpha channel of the image."
  2657.         ($editor + "maskPlaneItem");
  2658.  
  2659.     menuItem -divider true;
  2660.  
  2661.     menuItem 
  2662.         -label                     "Dithered" 
  2663.         -checkBox                true
  2664.         -command
  2665.             ("renderWindowMenuCommand dithered " + $editor) 
  2666.         -annotation
  2667.             ("Checked, image is displayed dithered but smooth "
  2668.                 + "scrolling. Unchecked, image is displayed undithered but "
  2669.                 + "flashes when scrolling.")
  2670.         ($editor + "ditheredItem");
  2671.     
  2672.     menuItem -divider true;
  2673.  
  2674.     menuItem 
  2675.         -label                     "Toolbar" 
  2676.         -checkBox                true
  2677.         -command
  2678.             ("renderWindowMenuCommand toolbar " + $editor) 
  2679.         -annotation
  2680.             "Show or hide the toolbar."
  2681.         ($editor + "toolbarItem");
  2682.  
  2683.     setParent -menu ..; // from Display menu
  2684.  
  2685.     // update the menuItem information.
  2686.     //
  2687.     refreshDisplayMenu($editor, $menuType);
  2688. }
  2689.  
  2690. global proc renderWindowMakeResolutionItem
  2691.  ( string $subMenuName,
  2692.    string $panelName )
  2693. {
  2694.     popupMenu -e -deleteAllItems $subMenuName;
  2695.     setParent -m $subMenuName;
  2696.  
  2697.     //
  2698.     //    Use panel resolution item.
  2699.     //
  2700.     int $testRes    = `optionVar -q renderViewTestResolution`;
  2701.     int    $panelBool    = ( $testRes == 0 );
  2702.     int $fullBool    = ( $testRes == 1 );
  2703.     int $halfBool    = ( $testRes == 2 );
  2704.     int $quaterBool    = ( $testRes == 3 );
  2705.     int $tenthBool    = ( $testRes == 4 );
  2706.     int $res[]        = `getGlobalsResolution`;
  2707.  
  2708.     menuItem -l "Camera Panel"
  2709.              -cb $panelBool
  2710.              -c "setTestResolutionVar(0)"
  2711.              ($panelName + "panelResolutionItem");
  2712.  
  2713.     menuItem -l ("Render Globals (" + $res[0] + "x" + $res[1] + ")")
  2714.              -cb $fullBool
  2715.              -c "setTestResolutionVar(1)"
  2716.              ($panelName + "fullResolutionItem");
  2717.  
  2718.     $x = $res[0] / 2;
  2719.     $y = $res[1] / 2;
  2720.     menuItem -l ("50% Globals (" + $x + "x" + $y + ")")
  2721.              -cb $halfBool
  2722.              -c "setTestResolutionVar(2)"
  2723.              ($panelName + "halfResolutionItem");
  2724.  
  2725.  
  2726.     $x = $res[0] / 4;
  2727.     $y = $res[1] / 4;
  2728.     menuItem -l ("25% Globals (" + $x + "x" + $y + ")")
  2729.              -cb $quaterBool
  2730.              -c "setTestResolutionVar(3)"
  2731.              ($panelName + "quaterResolutionItem");
  2732.  
  2733.     $x = $res[0] / 10;
  2734.     $y = $res[1] / 10;
  2735.     menuItem -l ("10% Globals (" + $x + "x" + $y + ")")
  2736.              -cb $tenthBool
  2737.              -c "setTestResolutionVar(4)"
  2738.              ($panelName + "tenthResolutionItem");
  2739. }
  2740.  
  2741. global proc renderWindowCreateCameraSubmenu(
  2742.     string    $subMenu,
  2743.     string    $command,
  2744.     string    $editor)
  2745. {
  2746.     popupMenu 
  2747.         -edit 
  2748.         -deleteAllItems 
  2749.         $subMenu;
  2750.  
  2751.     setParent 
  2752.         -menu 
  2753.         $subMenu;
  2754.  
  2755.     //
  2756.     //    Get the current model panel and then get the render view resolution.
  2757.     //
  2758.     string    $camera         = `getCurrentCamera`;
  2759.     string    $cameraPanel     = `getCameraPanel( $camera )`;
  2760.     int        $resolution[]    = `getTestResolution( $cameraPanel )`;
  2761.  
  2762.     //
  2763.     //    Build items.
  2764.     //
  2765.  
  2766.     // 
  2767.     // Create a menu item for the current camera
  2768.     //
  2769.     if( size($cameraPanel) != 0 )
  2770.     {
  2771.         menuItem 
  2772.             -label                 ("Current ("+$camera+")") 
  2773.             -command             ($command + $camera);
  2774.         menuItem -divider true ;
  2775.     }
  2776.  
  2777.     //
  2778.     // Create a menu item for each of the perspective cameras
  2779.     //
  2780.     string    $persps[] = `listCameras -perspective`;
  2781.  
  2782.     for( $camera in $persps )
  2783.     {
  2784.         menuItem 
  2785.             -label                 $camera 
  2786.             -command             ($command + $camera);
  2787.     }
  2788.  
  2789.     menuItem -divider true;
  2790.  
  2791.     //
  2792.     // Create a menu item for each of the orthographic cameras
  2793.     //
  2794.     string    $orthos[] = `listCameras -orthographic`;
  2795.  
  2796.     for( $camera in $orthos )
  2797.     {
  2798.         menuItem 
  2799.             -label                 $camera 
  2800.             -command             ($command + $camera);
  2801.     }
  2802. }
  2803.  
  2804. //////////////////////////////////////////////////////////////////////
  2805. //
  2806. //  Procedure Name:
  2807. //      buildRenderViewContextHelpItems
  2808. //
  2809. //  Description:
  2810. //        Build context sensitive menu items for the render view.  
  2811. //        
  2812. //  Input Arguments:
  2813. //        $nameRoot - name to use as the root of all item names
  2814. //        $menuParent - the name of the parent of this menu
  2815. //
  2816. //  Return Value:
  2817. //      None
  2818. //
  2819. global proc buildRenderViewContextHelpItems(string $nameRoot, string $menuParent)
  2820. {
  2821.     menuItem -label "Help on Render View..."
  2822.         -enableCommandRepeat false
  2823.         -command "showHelp RenderView";
  2824. }
  2825.  
  2826. global proc renderWindowRefreshMenu(string $menu, string $editor)
  2827. {
  2828.  
  2829.     if(`about -mac`){
  2830.         string  $panel = `getRenderWindowPanel`;
  2831.         string $renderPanels[] = `getPanel -vis`;
  2832.         int $count;
  2833.         for($count = 0; $count < size($renderPanels); $count++){
  2834.             if($renderPanels[$count] == $panel){
  2835.                 break;
  2836.             }
  2837.         }
  2838.         if ($count == size($renderPanels)){
  2839.             return;
  2840.         }
  2841.     }
  2842.     if ($menu == "file")
  2843.     {
  2844.         refreshFileMenu($editor, "menubar");
  2845.         refreshFileMenu($editor, "popup");
  2846.     }
  2847.     else if ($menu == "render")
  2848.     {
  2849.         refreshRenderMenu($editor, "menubar");
  2850.         refreshRenderMenu($editor, "popup");
  2851.     }
  2852.     else if ($menu == "ipr")
  2853.     {
  2854.         refreshIprMenu($editor, "menubar");
  2855.         refreshIprMenu($editor, "popup");
  2856.     }
  2857.     else if ($menu == "options")
  2858.     {
  2859.         refreshOptionsMenu($editor, "menubar");
  2860.         refreshOptionsMenu($editor, "popup");
  2861.     }
  2862.     else if ($menu == "view")
  2863.     {
  2864.         refreshViewMenu($editor, "menubar");
  2865.         refreshViewMenu($editor, "popup");
  2866.     }
  2867.     else if ($menu == "display")
  2868.     {
  2869.         refreshDisplayMenu($editor, "menubar");
  2870.         refreshDisplayMenu($editor, "popup");
  2871.     }
  2872. }
  2873.  
  2874. //----------------------------------------------------------------------------//
  2875. // Procedures which call the menu generation procedures and create other
  2876. // user interface elements within the render view window or panel
  2877. //----------------------------------------------------------------------------//
  2878.  
  2879. proc createMenubar(string $editor)
  2880. {
  2881.     createFileMenu($editor, "menubar");
  2882.     createViewMenu($editor, "menubar");
  2883.     createRenderMenu($editor, "menubar");
  2884.     createIprMenu($editor, "menubar");
  2885.     createOptionsMenu($editor, "menubar");
  2886.     createDisplayMenu($editor, "menubar");
  2887. }
  2888.  
  2889. proc createPopupMenu(string $editor)
  2890. {
  2891.     popupMenu
  2892.         -button                3
  2893.         -parent                $editor
  2894.         -allowOptionBoxes    true
  2895.         ($editor + "popupMenu");
  2896.  
  2897.     createFileMenu($editor, "popup");
  2898.     createViewMenu($editor, "popup");
  2899.     createRenderMenu($editor, "popup");
  2900.     createIprMenu($editor, "popup");
  2901.     createOptionsMenu($editor, "popup");
  2902.     createDisplayMenu($editor, "popup");
  2903. }
  2904.  
  2905.  
  2906.  
  2907. proc createLayout(string $editor)
  2908. {
  2909.     int $iconSize = 26;
  2910.     
  2911.     // Make sure that there is no template active
  2912.     setUITemplate -pushTemplate NONE;
  2913.  
  2914.     formLayout renderViewForm;
  2915.     formLayout toolbarForm;
  2916.         formLayout toolbar;
  2917.  
  2918.      string $currentRendererName = currentRenderer();
  2919.      string $renUIName = `renderer -query -rendererUIName $currentRendererName`;
  2920.  
  2921.             iconTextButton
  2922.                 -i1 "rvRender.xpm"
  2923.                 -width $iconSize -height $iconSize
  2924.                 -annotation ("Redo Previous Render (" +  $renUIName + ")")
  2925.                 -command
  2926.                     ("renderWindowRender redoPreviousRender " + $editor)
  2927.                 renderButton;
  2928.  
  2929.             iconTextButton
  2930.                 -i1 "rvIprRender.xpm"
  2931.                 -width $iconSize -height $iconSize
  2932.                 -annotation ("Redo Previous IPR Render (" +  $renUIName + ")")
  2933.                 -command
  2934.                     ("renderWindowRender redoPreviousIprRender " + $editor)
  2935.                 iprRenderButton;
  2936.  
  2937.             iconTextButton
  2938.                 -i1 "rvRenderRegion.xpm"
  2939.                 -width $iconSize -height $iconSize
  2940.                 -annotation ("Render Region (" +  $renUIName + ")")
  2941.                 -command
  2942.                     ("renderWindowRenderRegion " + $editor)
  2943.                 renderRegionButton;
  2944.  
  2945.             iconTextButton
  2946.                 -i1 "rvIPRRefresh.xpm" 
  2947.                 -width $iconSize -height $iconSize
  2948.                 -annotation ("Refresh the IPR Image (" +  $renUIName + ")")
  2949.                 -command 
  2950.                     ("renderWindowMenuCommand refreshIprImage "
  2951.                         + $editor)
  2952.                 refreshIprButton;
  2953.  
  2954.             iconTextButton
  2955.                 -i1 "rvAllPlanes.xpm"
  2956.                 -width $iconSize -height $iconSize
  2957.                 -annotation "Display RGB Channels"
  2958.                 -command                 
  2959.                     ("renderWindowEditor "
  2960.                      + "-edit "
  2961.                      + "-displayStyle \"color\" "
  2962.                      + "-scaleRed 1 "
  2963.                      + "-scaleGreen 1 "
  2964.                      + "-scaleBlue 1 " 
  2965.                      + $editor )
  2966.                 allPlanesButton;
  2967.  
  2968.             iconTextButton
  2969.                 -i1 "rvMaskPlane.xpm"
  2970.                 -width $iconSize -height $iconSize
  2971.                 -annotation "Display Alpha Channel"
  2972.                 -command                 
  2973.                     ("renderWindowEditor "
  2974.                      + "-edit "
  2975.                      + "-displayStyle \"mask\" " 
  2976.                      + $editor )
  2977.                 maskButton;
  2978.  
  2979.             iconTextButton
  2980.                 -i1 "rvRealSize.xpm"
  2981.                 -width $iconSize -height $iconSize
  2982.                 -annotation "Display Real Size"
  2983.                 -command
  2984.                     ("renderWindowEditor "
  2985.                      + "-edit "
  2986.                      + "-realSize "
  2987.                      + $editor)
  2988.                 realSizeButton;
  2989.  
  2990.             iconTextButton
  2991.                 -i1 "rvKeepIt.xpm"
  2992.                 -width $iconSize -height $iconSize
  2993.                 -annotation "Keep Image"
  2994.                 -command
  2995.                     ("renderWindowMenuCommand keepImageInRenderView " + $editor)
  2996.                 keepImageButton;
  2997.  
  2998.             iconTextButton
  2999.                 -i1 "rvRemoveIt.xpm"
  3000.                 -width $iconSize -height $iconSize
  3001.                 -annotation "Remove Image"
  3002.                 -command
  3003.                     ("renderWindowMenuCommand removeImageFromRenderView " + $editor)
  3004.                 removeImageButton;
  3005.  
  3006.             iconTextButton
  3007.                 -i1 "rvRenderGlobals.xpm"
  3008.                 -width $iconSize -height $iconSize
  3009.                 -annotation ("Open Render Globals Window (" +  $renUIName+ ")")
  3010.                 -command
  3011.                     ("displayRenderGlobalsWindow")
  3012.                 renderGlobalsButton;
  3013.  
  3014.             iconTextButton
  3015.                 -i1 "rvDiagnostics.xpm" 
  3016.                 -width $iconSize -height $iconSize
  3017.                 -annotation "Show Render Diagnostics in the Script Editor"
  3018.                 -command "mayaRenderDiagnostics" 
  3019.                 diagnosticsButton;
  3020.  
  3021.             iconTextCheckBox
  3022.                 -i1 "rvPauseIprTuning.xpm" 
  3023.                 -width $iconSize -height $iconSize
  3024.                 -annotation "Pause IPR Tuning"
  3025.                 -onCommand 
  3026.                     ("renderWindowMenuCommand togglePauseTuning " + $editor)
  3027.                 -offCommand 
  3028.                     ("renderWindowMenuCommand togglePauseTuning " + $editor)
  3029.                 pauseIprButton;
  3030.  
  3031.             text 
  3032.                 -label "IPR: 0MB"
  3033.                 iprMemEstText;
  3034.  
  3035.             iconTextButton
  3036.                 -i1 "rvIPRStop.xpm" 
  3037.                 -width $iconSize -height $iconSize
  3038.                 -annotation "Close IPR File and Stop Tuning"
  3039.                 -command 
  3040.                     ("renderWindowMenuCommand closeIprFile " + $editor)
  3041.                 closeIprButton;
  3042.  
  3043.             // Renderer selection option menu
  3044.             
  3045.             string $renderers[] = `renderer -query -namesOfAvailableRenderers`; 
  3046.             string $rendererUIName = "";
  3047.  
  3048.             optionMenu 
  3049.                     -annotation "Select Renderer" 
  3050.                     -cc  "updateCurrentRendererSel(\"rendererSelOptionMenu\")" 
  3051.                     rendererSelOptionMenu;
  3052.  
  3053.             for ($i = 0; $i < size($renderers); $i += 1)
  3054.             {
  3055.                 $rendererUIName = `renderer -query -rendererUIName $renderers[$i]`;
  3056.                 menuItem -l $rendererUIName -enableCommandRepeat false ("rendererSelOptionMenuItem" +$i);
  3057.             }
  3058.  
  3059.             // Update the Renderer selection option box to reflect current renderer
  3060.             //
  3061.             for ($i = 0; $i < size($renderers); $i++)
  3062.             {
  3063.                 if($renderers[$i] == currentRenderer())
  3064.                 {
  3065.                     optionMenu -edit -select ($i+1) rendererSelOptionMenu;
  3066.                 }
  3067.             }
  3068.  
  3069.             separator -horizontal false -style single rvSeparator1;
  3070.             separator -horizontal false -style single rvSeparator2;
  3071.             separator -horizontal false -style single rvSeparator3;
  3072.             separator -horizontal false -style single rvSeparator4;
  3073.             separator -horizontal false -style single rvSeparator5;
  3074.             separator -horizontal false -style single rightSeparator;
  3075.  
  3076.             int $margin = 1;
  3077.  
  3078.             formLayout
  3079.                 -edit
  3080.  
  3081.                 -attachForm        "renderButton"       "left"     $margin
  3082.                 -attachNone     "renderButton"       "right"
  3083.                 -attachForm     "renderButton"       "top"     $margin
  3084.                 -attachForm     "renderButton"       "bottom" $margin
  3085.  
  3086.                 -attachControl    "renderRegionButton"      "left"     $margin "renderButton"
  3087.                 -attachNone     "renderRegionButton"      "right"
  3088.                 -attachForm     "renderRegionButton"      "top"     $margin
  3089.                 -attachForm     "renderRegionButton"      "bottom" $margin
  3090.  
  3091.                 -attachControl    "rvSeparator1"      "left"     $margin "renderRegionButton"
  3092.                 -attachNone     "rvSeparator1"      "right"
  3093.                 -attachForm     "rvSeparator1"      "top"     $margin
  3094.                 -attachForm     "rvSeparator1"      "bottom" $margin
  3095.  
  3096.                 -attachControl    "iprRenderButton"      "left"     $margin "rvSeparator1"
  3097.                 -attachNone     "iprRenderButton"      "right"
  3098.                 -attachForm     "iprRenderButton"      "top"     $margin
  3099.                 -attachForm     "iprRenderButton"      "bottom" $margin
  3100.  
  3101.                 -attachControl  "refreshIprButton"  "left"     $margin "iprRenderButton"
  3102.                 -attachNone     "refreshIprButton"  "right"
  3103.                 -attachForm     "refreshIprButton"  "top"     $margin
  3104.                 -attachForm     "refreshIprButton"  "bottom" $margin
  3105.  
  3106.                 -attachControl    "rvSeparator2"      "left"     $margin "refreshIprButton"
  3107.                 -attachNone     "rvSeparator2"      "right"
  3108.                 -attachForm     "rvSeparator2"      "top"     $margin
  3109.                 -attachForm     "rvSeparator2"      "bottom" $margin
  3110.  
  3111.                 -attachControl  "renderGlobalsButton" "left"     $margin "rvSeparator2"
  3112.                 -attachNone     "renderGlobalsButton" "right"
  3113.                 -attachForm     "renderGlobalsButton" "top"     $margin
  3114.                 -attachForm     "renderGlobalsButton" "bottom"      $margin
  3115.  
  3116.                 -attachControl    "rvSeparator3"      "left"     $margin "renderGlobalsButton"
  3117.                 -attachNone     "rvSeparator3"      "right"
  3118.                 -attachForm     "rvSeparator3"      "top"     $margin
  3119.                 -attachForm     "rvSeparator3"      "bottom" $margin
  3120.  
  3121.                 -attachControl    "allPlanesButton"   "left"     $margin "rvSeparator3"
  3122.                 -attachNone     "allPlanesButton"   "right"
  3123.                 -attachForm     "allPlanesButton"   "top"     $margin
  3124.                 -attachForm     "allPlanesButton"   "bottom" $margin
  3125.  
  3126.                 -attachControl  "maskButton"        "left"     $margin "allPlanesButton"
  3127.                 -attachNone     "maskButton"        "right"
  3128.                 -attachForm     "maskButton"        "top"     $margin
  3129.                 -attachForm     "maskButton"        "bottom" $margin
  3130.  
  3131.                 -attachControl  "realSizeButton"    "left"     $margin "maskButton"
  3132.                 -attachNone     "realSizeButton"    "right"
  3133.                 -attachForm     "realSizeButton"    "top"     $margin
  3134.                 -attachForm     "realSizeButton"    "bottom" $margin
  3135.  
  3136.                 -attachControl    "rvSeparator4"      "left"     $margin "realSizeButton"
  3137.                 -attachNone     "rvSeparator4"      "right"
  3138.                 -attachForm     "rvSeparator4"      "top"     $margin
  3139.                 -attachForm     "rvSeparator4"      "bottom" $margin
  3140.  
  3141.                 -attachControl  "keepImageButton"   "left"     $margin "rvSeparator4"
  3142.                 -attachNone     "keepImageButton"   "right"
  3143.                 -attachForm     "keepImageButton"   "top"     $margin
  3144.                 -attachForm     "keepImageButton"   "bottom"      $margin
  3145.  
  3146.                 -attachControl  "removeImageButton" "left"     $margin "keepImageButton"
  3147.                 -attachNone     "removeImageButton" "right"
  3148.                 -attachForm     "removeImageButton" "top"     $margin
  3149.                 -attachForm     "removeImageButton" "bottom"      $margin
  3150.  
  3151.                 -attachControl    "rvSeparator5"      "left"     $margin "removeImageButton"
  3152.                 -attachNone     "rvSeparator5"      "right"
  3153.                 -attachForm     "rvSeparator5"      "top"     $margin
  3154.                 -attachForm     "rvSeparator5"      "bottom" $margin
  3155.  
  3156.                 -attachControl  "diagnosticsButton"    "left"     $margin "rvSeparator5"
  3157.                 -attachNone     "diagnosticsButton"    "right"
  3158.                 -attachForm     "diagnosticsButton"    "top"     $margin
  3159.                 -attachForm     "diagnosticsButton"    "bottom" $margin
  3160.  
  3161.                 -attachControl    "rightSeparator"      "left"     $margin "diagnosticsButton"
  3162.                 -attachNone     "rightSeparator"      "right"
  3163.                 -attachForm     "rightSeparator"      "top"     $margin
  3164.                 -attachForm     "rightSeparator"      "bottom" $margin
  3165.  
  3166.                 -attachControl    "rendererSelOptionMenu"      "left"     $margin "rightSeparator"
  3167.                 -attachNone     "rendererSelOptionMenu"      "right"
  3168.                 -attachForm     "rendererSelOptionMenu"      "top"     $margin
  3169.                 -attachForm     "rendererSelOptionMenu"      "bottom" $margin
  3170.                 
  3171.                 -attachNone        "closeIprButton"    "left" 
  3172.                 -attachForm     "closeIprButton"    "right"     $margin
  3173.                 -attachForm     "closeIprButton"    "top"     $margin
  3174.                 -attachForm     "closeIprButton"    "bottom" $margin
  3175.  
  3176.                 -attachNone        "iprMemEstText"        "left" 
  3177.                 -attachControl  "iprMemEstText"        "right"  $margin "closeIprButton"
  3178.                 -attachForm     "iprMemEstText"        "top"     $margin
  3179.                 -attachForm     "iprMemEstText"        "bottom" $margin
  3180.  
  3181.                 -attachNone        "pauseIprButton"    "left" 
  3182.                 -attachControl  "pauseIprButton"    "right"  $margin "iprMemEstText"
  3183.                 -attachForm     "pauseIprButton"    "top"     $margin
  3184.                 -attachForm     "pauseIprButton"    "bottom" $margin
  3185.  
  3186.                 toolbar;
  3187.  
  3188.         setParent ..;
  3189.         formLayout
  3190.             -edit
  3191.             -attachForm    "toolbar"    "left"        0
  3192.             -attachForm    "toolbar"    "right"        0
  3193.             -attachForm    "toolbar"    "top"        0
  3194.             -attachForm    "toolbar"    "bottom"    0
  3195.             toolbarForm;
  3196.     setParent ..;
  3197.  
  3198.     formLayout editorForm;
  3199.         renderWindowEditor 
  3200.             -edit
  3201.             -parent "editorForm"
  3202.             $editor;
  3203.         formLayout
  3204.             -edit
  3205.             -attachForm    $editor    "left"        0
  3206.             -attachForm    $editor    "right"        0
  3207.             -attachForm    $editor    "top"        0
  3208.             -attachForm    $editor    "bottom"    0
  3209.             editorForm;
  3210.     setParent ..;
  3211.  
  3212.     formLayout scrollBarForm;
  3213.         intScrollBar  
  3214.             -step 1
  3215.             -largeStep 1
  3216.             -height    15
  3217.             -horizontal true
  3218.             -changeCommand 
  3219.                 ("renderWindowScrollDisplayImage " 
  3220.                     + $editor) 
  3221.             scrollBar;
  3222.         formLayout
  3223.             -edit
  3224.             -attachForm    "scrollBar"    "left"        0
  3225.             -attachForm    "scrollBar"    "right"        0
  3226.             -attachForm    "scrollBar"    "top"        0
  3227.             -attachForm    "scrollBar"    "bottom"    0
  3228.             scrollBarForm;
  3229.     setParent ..;
  3230.     
  3231.     //    Needed on Mac :
  3232.     //    Add an offset for right attachment of the scrollBar.
  3233.     //    This prevents resize handle of window from overlapping 
  3234.     //    onto the scrollbar's up/down arrows
  3235.     //
  3236.     int $scrollBarRightSpacing, $editorFormBottomSpacing;
  3237.     if (`about -mac`) {
  3238.         $scrollBarRightSpacing = 12;
  3239.         $editorFormBottomSpacing = 10;
  3240.     } else {
  3241.         $scrollBarRightSpacing = 0;
  3242.         $editorFormBottomSpacing = 0;
  3243.     }
  3244.  
  3245.     formLayout
  3246.         -edit
  3247.         
  3248.         -attachForm        "toolbarForm"        "left"        0
  3249.         -attachForm        "toolbarForm"        "right"        0
  3250.         -attachForm        "toolbarForm"        "top"        0
  3251.         -attachNone        "toolbarForm"        "bottom"
  3252.  
  3253.         -attachForm        "editorForm"        "left"        0
  3254.         -attachForm        "editorForm"        "right"        0
  3255.         -attachControl    "editorForm"        "top"        0 "toolbarForm"
  3256.         -attachControl    "editorForm"        "bottom"    $editorFormBottomSpacing "scrollBarForm"
  3257.  
  3258.         -attachForm        "scrollBarForm"        "left"        0
  3259.         -attachForm        "scrollBarForm"        "right"        $scrollBarRightSpacing
  3260.         -attachNone        "scrollBarForm"        "top"
  3261.         -attachForm        "scrollBarForm"        "bottom"    0
  3262.  
  3263.         renderViewForm;
  3264.         
  3265.     createPopupMenu($editor);
  3266.     
  3267.     setUITemplate -popTemplate;
  3268. }
  3269.  
  3270. // Description:  This procedure is called to refresh the renderer specific
  3271. //  in the render view window.
  3272. //
  3273. proc renderWindowRendererSpecificRefresh(string $parent)
  3274. {
  3275.     setParent $parent;
  3276.  
  3277.      string $currentRendererName = currentRenderer();
  3278.      string $renUIName = `renderer -query -rendererUIName $currentRendererName`;
  3279.  
  3280.     // Refresh captions of render buttons to update current renderer tag
  3281.     //
  3282.     iconTextButton -edit
  3283.                 -annotation ("Redo Previous Render (" +  $renUIName+ ")")
  3284.                 renderButton;
  3285.     
  3286.     iconTextButton -edit
  3287.                 -annotation ("Render Region (" +  $renUIName+ ")")
  3288.                 renderRegionButton;
  3289.  
  3290.     iconTextButton -edit
  3291.                 -annotation ("Open Render Globals Window (" +  $renUIName+ ")")
  3292.                 renderGlobalsButton;
  3293.  
  3294.     global int $gIprTuningPaused;
  3295.  
  3296.     if (`renderer -query -iprRenderProcedure $currentRendererName` != "") 
  3297.     {
  3298.         // enable IPR related UI if current renderer supports IPR
  3299.         //
  3300.         iconTextButton -edit 
  3301.                     -enable true
  3302.                     -annotation ("Redo Previous IPR Render (" +  $renUIName+ ")")
  3303.                     iprRenderButton;
  3304.  
  3305.         if (isIprFileLoaded()) {
  3306.             text -edit -enable true iprMemEstText;
  3307.             iconTextButton -edit 
  3308.                     -enable true
  3309.                     -annotation ("Close IPR File and Stop Tuning")
  3310.                     closeIprButton;
  3311.  
  3312.             iconTextCheckBox -edit 
  3313.                     -enable true
  3314.                     -annotation ("Pause IPR Tuning")
  3315.                     pauseIprButton;
  3316.  
  3317.             iconTextButton -edit 
  3318.                     -enable (!$gIprTuningPaused) 
  3319.                     -annotation ("Refresh the IPR Image (" +  $renUIName+ ")")
  3320.                     refreshIprButton;
  3321.         } else {
  3322.             text -edit -enable false iprMemEstText;
  3323.             iconTextButton -edit 
  3324.                     -enable false
  3325.                     -annotation ("")
  3326.                     closeIprButton;
  3327.  
  3328.             iconTextCheckBox -edit 
  3329.                     -enable false 
  3330.                     -annotation ("")
  3331.                     pauseIprButton;
  3332.  
  3333.             iconTextButton -edit 
  3334.                     -enable false
  3335.                     -annotation ("")
  3336.                     refreshIprButton;
  3337.         }
  3338.  
  3339.         // Adjust the "Pause IPR Tuning" icon to be pressed if tuning is paused,
  3340.         // or not pressed if tuning is not paused.
  3341.         //
  3342.         if ($gIprTuningPaused)
  3343.         {
  3344.             iconTextCheckBox -edit -value true pauseIprButton;
  3345.         }
  3346.         else
  3347.         {
  3348.             iconTextCheckBox -edit -value false pauseIprButton;
  3349.         }
  3350.  
  3351.     }
  3352.     else
  3353.     {
  3354.         // If the current renderer does not support IPR, disable all
  3355.         // ipr related UI
  3356.                     //
  3357.         text -edit -enable false iprMemEstText;
  3358.  
  3359.         iconTextButton -edit 
  3360.                 -enable false
  3361.                 -annotation ("Not available for this renderer")
  3362.                 closeIprButton;
  3363.  
  3364.         iconTextCheckBox -edit 
  3365.                 -enable false 
  3366.                 -annotation ("Not available for this renderer")
  3367.                 pauseIprButton;
  3368.  
  3369.         iconTextButton -edit 
  3370.                 -enable false
  3371.                 -annotation ("Not available for this renderer")
  3372.                 refreshIprButton;
  3373.  
  3374.         iconTextCheckBox -edit -value false pauseIprButton;
  3375.  
  3376.         iconTextButton -edit 
  3377.                 -enable false
  3378.                 -annotation ("Not available for this renderer")
  3379.                 iprRenderButton;
  3380.     }
  3381.  
  3382.     // Disable render diagnostics button if the feature is not 
  3383.     // supported by the current renderer
  3384.     //
  3385.     if (`renderer -query -renderDiagnosticsProcedure $currentRendererName` != "") 
  3386.     {
  3387.         iconTextButton -edit 
  3388.                 -enable true
  3389.                 -annotation ("Show Render Diagnostics in the Script Editor")
  3390.                  diagnosticsButton;
  3391.     }
  3392.     else
  3393.     {
  3394.         iconTextButton -edit 
  3395.                     -enable false
  3396.                     -annotation ("")
  3397.                      diagnosticsButton;
  3398.     }
  3399.  
  3400.  
  3401.     string $renderers[] = `renderer -query -namesOfAvailableRenderers`; 
  3402.  
  3403.     // Check for any updates in the renderer list
  3404.     //
  3405.     int $numItems = `optionMenu -query -numberOfItems rendererSelOptionMenu`;
  3406.  
  3407.     // Make sure all the renderers are being shown in the option menu
  3408.     //
  3409.     if($numItems != size($renderers))
  3410.     {
  3411.  
  3412.         setParent -menu rendererSelOptionMenu;
  3413.  
  3414.         string $menuItemNames[] = `optionMenu -query -itemListLong rendererSelOptionMenu`;
  3415.  
  3416.         // Remove all the menuItems and create new ones to reflect the 
  3417.         // renderers currently available
  3418.         //
  3419.         for ($i = 0; $i < size($menuItemNames); $i++)
  3420.         {
  3421.             deleteUI $menuItemNames[$i];
  3422.         }
  3423.     
  3424.         for ($i = 0; $i < size($renderers); $i++)
  3425.         {
  3426.             $rendererUIName = `renderer -query -rendererUIName $renderers[$i]`;
  3427.             menuItem -l $rendererUIName -enableCommandRepeat false ("rendererSelOptionMenuItem" +$i);
  3428.         }
  3429.  
  3430.         setParent ..;
  3431.         
  3432.     }
  3433.  
  3434.     // Update the Renderer selection option box to reflect current renderer
  3435.     //
  3436.     
  3437.     for ($i = 0; $i < size($renderers); $i++)
  3438.     {
  3439.         if($renderers[$i] == currentRenderer())
  3440.         {
  3441.             optionMenu -edit -select ($i+1) rendererSelOptionMenu;
  3442.         }
  3443.     }
  3444. }
  3445.  
  3446. global proc renderWindowRefreshLayout(string $editor)
  3447. {
  3448.  
  3449.     if(`about -mac`){
  3450.         string  $panel = `getRenderWindowPanel`;
  3451.         string $renderPanels[] = `getPanel -vis`;
  3452.         int $count;
  3453.         for($count = 0; $count < size($renderPanels); $count++){
  3454.             if($renderPanels[$count] == $panel){
  3455.                 break;
  3456.             }
  3457.         }
  3458.         if ($count == size($renderPanels)){
  3459.             return;
  3460.         }
  3461.     }
  3462.     setParent $editor;
  3463.     formLayout -edit -manage false renderViewForm;
  3464.  
  3465.     if (isToolbarDisplayed())
  3466.     {
  3467.         formLayout
  3468.             -edit
  3469.             -manage true
  3470.             toolbar;
  3471.     }
  3472.     else
  3473.     {
  3474.         formLayout
  3475.             -edit
  3476.             -manage false
  3477.             toolbar;
  3478.     }
  3479.  
  3480.     //
  3481.     // Refresh the scroll bar
  3482.     //
  3483.  
  3484.     // Determine how many images are stored in the buffer
  3485.     //
  3486.     int $numImages = 
  3487.         `renderWindowEditor 
  3488.             -query
  3489.             -nbImages
  3490.             $editor`;
  3491.  
  3492.     // Determine what the index of the current image is
  3493.     //
  3494.     int $currImage = 
  3495.         `renderWindowEditor
  3496.             -query
  3497.             -displayImage
  3498.             $editor`;
  3499.     
  3500.     if ($numImages > 0)
  3501.     {
  3502.         // There is at least one image in the buffer, so we should display the
  3503.         // scroll bar with appropriate max, min and index.
  3504.         //
  3505.         intScrollBar
  3506.             -edit
  3507.             -manage        true
  3508.             -min         -1
  3509.             -max        ($numImages - 1)
  3510.             -value        $currImage
  3511.             scrollBar;        
  3512.                         
  3513.         //    Fix for Bug #147008
  3514.         //    Adjust the editor form bottom,
  3515.         //    so that it does not overlap onto window resize handle
  3516.         //
  3517.         if(`about -mac`) 
  3518.         {
  3519.             int $scrollBarRightSpacing = 12 ;
  3520.     
  3521.             formLayout
  3522.             -edit
  3523.  
  3524.             -attachForm        "toolbarForm"        "left"        0
  3525.             -attachForm        "toolbarForm"        "right"        0
  3526.             -attachForm        "toolbarForm"        "top"        0
  3527.             -attachNone        "toolbarForm"        "bottom"
  3528.  
  3529.             -attachForm        "editorForm"        "left"        0
  3530.             -attachForm        "editorForm"        "right"        0
  3531.             -attachControl    "editorForm"        "top"        0 "toolbarForm"
  3532.             -attachControl    "editorForm"        "bottom"    0 "scrollBarForm"
  3533.  
  3534.             -attachForm        "scrollBarForm"        "left"        0
  3535.             -attachForm        "scrollBarForm"        "right"        $scrollBarRightSpacing
  3536.             -attachNone        "scrollBarForm"        "top"
  3537.             -attachForm        "scrollBarForm"        "bottom"    0
  3538.  
  3539.             renderViewForm;
  3540.          }
  3541.     }
  3542.     else
  3543.     {
  3544.         // There aren't any images in the buffer.
  3545.         // Hide the scroll bar.
  3546.         //
  3547.         intScrollBar
  3548.             -edit
  3549.             -manage    false
  3550.             scrollBar;
  3551.  
  3552.         //    Fix for Bug #147008
  3553.         //    Adjust the editor form bottom,
  3554.         //    so that it does not overlap onto window resize handle
  3555.         //
  3556.         if(`about -mac`) 
  3557.         {            
  3558.             int $scrollBarRightSpacing = 12 ;
  3559.             int $editorFormBottomSpacing = 10 ;
  3560.     
  3561.             formLayout
  3562.             -edit
  3563.  
  3564.             -attachForm        "toolbarForm"        "left"        0
  3565.             -attachForm        "toolbarForm"        "right"        0
  3566.             -attachForm        "toolbarForm"        "top"        0
  3567.             -attachNone        "toolbarForm"        "bottom"
  3568.  
  3569.             -attachForm        "editorForm"        "left"        0
  3570.             -attachForm        "editorForm"        "right"        0
  3571.             -attachControl    "editorForm"        "top"        0 "toolbarForm"
  3572.             -attachControl    "editorForm"        "bottom"    $editorFormBottomSpacing "scrollBarForm"
  3573.  
  3574.             -attachForm        "scrollBarForm"        "left"        0
  3575.             -attachForm        "scrollBarForm"        "right"        $scrollBarRightSpacing
  3576.             -attachNone        "scrollBarForm"        "top"
  3577.             -attachForm        "scrollBarForm"        "bottom"    0
  3578.  
  3579.             renderViewForm;
  3580.          }
  3581.     }
  3582.  
  3583.     // Refresh the renderer specific UIs in render window layout.
  3584.     //
  3585.     string $currentParent = `setParent -q`;
  3586.     renderWindowRendererSpecificRefresh($currentParent);
  3587.  
  3588.     formLayout -edit -manage true renderViewForm;
  3589. }
  3590.  
  3591. //----------------------------------------------------------------------------//
  3592. // Procedures which are accessed from outside the renderview
  3593. //----------------------------------------------------------------------------//
  3594.  
  3595. global proc renderIntoNewWindow(string $renderMode)
  3596. {
  3597.     // Determine what model panel the user wants to render.
  3598.     //
  3599.     string $currentPanel = `getPanel -wf`;
  3600.     string $camera = "";
  3601.  
  3602.     if( `getPanel -to $currentPanel` != "modelPanel" )
  3603.     {
  3604.         if (`getPanel -to $currentPanel` == "scriptedPanel") {
  3605.             // It is potentially a Paint Effects panel.
  3606.             if ( `scriptedPanel -q -l $currentPanel` == "Paint Effects" ) {
  3607.                 // It is! It is a Paint Effects panel. Get the name of the camera we are using.
  3608.                 if (`about -mac`) {
  3609.                     // Temporary fix for 4.5. getPanel needs to be properly fixed in 5.0 for Mac.
  3610.                     string $dynPanel = `getPanel -containing dynPaintScriptedPanelEd`;
  3611.                     if ((size($dynPanel) != 0)) {
  3612.                         $camera = `dynPaintEditor -query -camera dynPaintScriptedPanelEd`;
  3613.                     }
  3614.                 } else {
  3615.                         $camera = `dynPaintEditor -query -camera dynPaintScriptedPanelEd`;
  3616.                 }
  3617.             }
  3618.         }
  3619.         if ($camera == "") {
  3620.             confirmDialog 
  3621.                 -message "Please select the view you want to render" 
  3622.                 -button "OK" 
  3623.                 -defaultButton "OK";
  3624.             return;
  3625.         }
  3626.     }
  3627.     else
  3628.     {
  3629.         // Find out what the current camera is
  3630.         //
  3631.         $camera = `modelPanel -query -camera $currentPanel`;
  3632.     }
  3633.  
  3634.     // Get the render view.
  3635.     //
  3636.     string $editor = `getRenderWindowPanel`;
  3637.  
  3638.     //
  3639.     // If not tore off, do It !
  3640.     //
  3641.     if( !`scriptedPanel -q -tearOff $editor` )
  3642.     {
  3643.         scriptedPanel -e -tearOff $editor;
  3644.     }
  3645.  
  3646.     //
  3647.     //    Now gets the right resolution.
  3648.     //
  3649.     int        $res[] = `getTestResolution( $currentPanel )`;
  3650.  
  3651.     //
  3652.     //    If the render view is too small, resize it.
  3653.     //
  3654.     string    $renderWindowControl = `scriptedPanel -q -control $editor`;
  3655.     string    $renderWindow;
  3656.     string    $buffer[];
  3657.  
  3658.     tokenize( $renderWindowControl, "|", $buffer );
  3659.     $renderWindow = $buffer[0];
  3660.  
  3661.     int        $width = `control -q -w $renderWindowControl`;
  3662.     int        $height = `control -q -h $renderWindowControl`;
  3663.  
  3664.     $width -= 40;
  3665.     $height -= 60;
  3666.  
  3667.     if( $width < $res[0] || $height < $res[1] )
  3668.     {
  3669.         $width = $res[0] + 40;
  3670.         $height = $res[1] + 60;
  3671.         window -e -w $width -h $height -retain $renderWindow;
  3672.     }
  3673.  
  3674.     //
  3675.     //    Render the current camera panel at the test resolution...
  3676.     //
  3677.     showWindow $renderWindow;
  3678.  
  3679.     renderWindowRenderCamera($renderMode, $editor, $camera);
  3680. }
  3681.  
  3682.  
  3683. //    This one can be used by hotkeys to check whether the render view is
  3684. //    visible or not before calling redoLastRender procedure.
  3685. //
  3686. global proc redoPreviousRender(string $renderMode)
  3687. {
  3688.     string $editor = `showRenderView`;
  3689.     renderWindowRender($renderMode, $editor);
  3690. }
  3691.  
  3692. global proc renderWindowScrollDisplayImage(string $editor)
  3693. {
  3694.     int $index  = 
  3695.         `intScrollBar 
  3696.             -query 
  3697.             -value 
  3698.             scrollBar`;
  3699.     
  3700.     renderWindowEditor
  3701.         -edit
  3702.         -displayImage $index
  3703.         $editor;
  3704.  
  3705.     renderWindowRefreshMenu("file", $editor);
  3706. }
  3707.  
  3708. //----------------------------------------------------------------------------//
  3709. // Procedures which support scripted panel capability
  3710. //----------------------------------------------------------------------------//
  3711.  
  3712. global proc createRenderWindowPanel(string $whichPanel)
  3713. {
  3714.     renderWindowEditor  -unParent  $whichPanel ;
  3715.  
  3716.     //
  3717.     //    Set the options variables.
  3718.     //
  3719.     setRenderOptionVars;
  3720.     
  3721.     //    Adds support for the Context Sensitive Help Menu.
  3722.     //
  3723.     addContextHelpProc $whichPanel "buildRenderViewContextHelpItems";        
  3724. }
  3725.  
  3726. global proc addRenderWindowPanel(string $editor)
  3727. {        
  3728.     //
  3729.     //  Build Menubar.
  3730.     //
  3731.     createMenubar($editor);
  3732.  
  3733.     // Create the layout of the renderview
  3734.     //
  3735.     createLayout($editor);
  3736.     renderWindowRefreshLayout($editor);
  3737.  
  3738.     //
  3739.     //    Tells the renderWindowEditor what the renderViewAutoResize value
  3740.     //    is.
  3741.     //
  3742.     $var = `optionVar -q renderViewAutoResize`;
  3743.     renderWindowEditor -e -ar $var $editor;
  3744. }
  3745.  
  3746. global proc removeRenderWindowPanel(string $whichPanel)
  3747. {
  3748.     renderWindowEditor -e -unParent $whichPanel ;
  3749. }
  3750.  
  3751.  
  3752. global proc renderWindowPanel(string $panelName) 
  3753. //
  3754. //  Description:
  3755. //        This proc defines the render window panel type and instantiates
  3756. //        one.
  3757. //
  3758. {
  3759.     global string $gMainPane;
  3760.  
  3761.     //  Define the type of panel and its callbacks
  3762.     //
  3763.     if (!`scriptedPanelType -exists renderWindowPanel`) 
  3764.     {
  3765.         scriptedPanelType
  3766.             -unique true
  3767.             -createCallback     "createRenderWindowPanel" 
  3768.             -addCallback         "addRenderWindowPanel" 
  3769.             -removeCallback     "removeRenderWindowPanel" 
  3770.             renderWindowPanel;
  3771.  
  3772.         //  Create an instance of the render window panel
  3773.         //
  3774.         setParent $gMainPane;
  3775.         scriptedPanel -unParent -type "renderWindowPanel" $panelName;
  3776.     }
  3777. }
  3778.  
  3779. //
  3780. // Description:
  3781. //        This procedure is called by TrenderWindowSelectCtx.cc that defines
  3782. //    a region. It checks if a region can be rendered.
  3783. //
  3784. global proc renderWindowCheckAndRenderRegion
  3785.  ( float    $top,
  3786.    float    $left,
  3787.    float    $bottom,
  3788.    float    $right )
  3789. {    
  3790.     //
  3791.     //    If there's no current camera (first render), do what has to be
  3792.     //    done...
  3793.     //
  3794.     string    $renderPanel = `getRenderWindowPanel`;
  3795.     int        $snapped = 0;
  3796.  
  3797.     if (!isIprFileLoaded()) {
  3798.         if( `renderWindowEditor -q -currentCamera $renderPanel` == "" )
  3799.         {
  3800.             //
  3801.             //    Take a snapshot of the first persp camera found.
  3802.             //
  3803.             string $cameras[] = `listCameras -perspective`;
  3804.  
  3805.             if( size($cameras) )
  3806.             {
  3807.                 string    $camera = $cameras[0];
  3808.                 string    $panel = `getCameraPanel( $camera )`;
  3809.                 int        $res[] = `getTestResolution( $panel )`;
  3810.  
  3811.                 renderWindowTakeSnapshot( $res[0], $res[1], $camera );
  3812.                 $snapped = 1;
  3813.             }
  3814.             else
  3815.             {
  3816.                 $cameras = `listCameras`;
  3817.  
  3818.                 if( size($cameras) )
  3819.                 {
  3820.                     string    $camera = $cameras[0];
  3821.                     string    $panel = `getCameraPanel( $camera )`;
  3822.                     int        $res[] = `getTestResolution( $panel )`;
  3823.  
  3824.                     renderWindowTakeSnapshot( $res[0], $res[1], $camera );
  3825.                     $snapped = 1;
  3826.                 }
  3827.             }
  3828.         }
  3829.         else
  3830.             $snapped = 1;
  3831.     } else
  3832.         $snapped = 1;
  3833.  
  3834.  
  3835.     //
  3836.     //    Otherwise, set the region and render if the renderViewAutoRenderRegion
  3837.     //    is set to true.
  3838.     //
  3839.     if( $snapped )
  3840.     {
  3841.         renderWindowEditor -e -mq $top $left $bottom $right $renderPanel;
  3842.  
  3843.         // We can't autoRenderRegion if ipr is on
  3844.         if( `optionVar -exists renderViewAutoRenderRegion` &&
  3845.             `optionVar -query renderViewAutoRenderRegion` != 0 &&
  3846.             !isIprFileLoaded())
  3847.         {
  3848.                 string $editor = `showRenderView`;
  3849.                 renderWindowRenderRegion($editor);
  3850.         }
  3851.             
  3852.     }
  3853.  
  3854.     if (isIprFileLoaded())
  3855.     {
  3856.         global int $gIprTuningPaused;
  3857.  
  3858.         if ($gIprTuningPaused)
  3859.         {
  3860.             renderWindowMenuCommand("togglePauseTuning", $renderPanel);
  3861.         }
  3862.  
  3863.         // Tell the IPR engine what the current marquee is
  3864.         //
  3865.         int $top;
  3866.         int $left;
  3867.         int $bottom;
  3868.         int $right;
  3869.  
  3870.         string $renderGlobals[] = `ls -renderGlobals`;
  3871.  
  3872.         $bottom = `getAttr ($renderGlobals[0] + ".bottomRegion")`;
  3873.         $left     = `getAttr ($renderGlobals[0] + ".leftRegion")`;
  3874.         $top    = `getAttr ($renderGlobals[0] + ".topRegion")`;
  3875.         $right     = `getAttr ($renderGlobals[0] + ".rightRegion")`;
  3876.  
  3877.         iprEngine
  3878.             -edit
  3879.             -region $left $bottom $right $top
  3880.             defaultIprEngine;
  3881.  
  3882.         loadSamples($renderPanel);
  3883.     }
  3884. }
  3885.  
  3886. //
  3887. // Description:
  3888. //            This procedure is called when an image is to be rendered using 
  3889. //            the maya renderer. It is used to standardize the render command 
  3890. //            calls , since not all renderers take the same arguments
  3891. //     Returns: render result
  3892. //
  3893. global proc string mayaSoftwareRender(int $width, int $height, int $doShadows,
  3894.                                       int $doGlowPass, string $camera)
  3895. {
  3896.     string $result;
  3897.     $result = `render -x $width -y $height -nsh $doShadows 
  3898.                 -ngl $doGlowPass $camera`;
  3899.     return $result;
  3900. }
  3901.  
  3902. //
  3903. // Description:
  3904. //            Checks if the current render supports the reder region feature
  3905. //            and if so, calls the render region procedure for the current renderer.
  3906. //    Returns: None
  3907. //
  3908. global proc renderWindowRenderRegion(string $editor)
  3909. {
  3910.     string $command;
  3911.     
  3912.  
  3913.     string $renderer;
  3914.  
  3915.     $renderer = currentRenderer();
  3916.     string $renUIName = `renderer -query -rendererUIName $renderer`;
  3917.  
  3918.     // if render region is support calls the corresponding
  3919.     // procedure for the current renderer
  3920.     //
  3921.     $command = `renderer -query -renderRegionProcedure $renderer`;
  3922.     if ($command != "")
  3923.     {
  3924.         catch($result = `eval $command $editor`);
  3925.  
  3926.         renderWindowEditor 
  3927.             -edit 
  3928.             -pca ($renUIName) 
  3929.             $editor;
  3930.     }
  3931.     else
  3932.     {
  3933.         // Feature not supported: report error
  3934.         //
  3935.         warning
  3936.             ("Current Renderer " 
  3937.                 + $renUIName
  3938.                 + " does not support render region");
  3939.     }    
  3940. }
  3941.  
  3942. //
  3943. // Description: 
  3944. //            This procedure is called when a render region command is issued 
  3945. //            for the maya software renderer. It is used to standardize the render
  3946. //            command calls , since not all renderers take the same arguments
  3947. //     Returns: render result            
  3948. //
  3949. global proc mayaRenderRegion(string $editor)
  3950. {
  3951.     string $cmd = "renderWindowRender renderRegion";
  3952.     eval $cmd $editor;
  3953. }
  3954.  
  3955.  
  3956. //
  3957. // Description: Builds the "Render Using" Menu to allow for renderer selection
  3958. // Returns: None
  3959. //
  3960. global proc buildRenderUsingMenu
  3961.  ( string $subMenuName,
  3962.    string $panelName )
  3963. {
  3964.     popupMenu -e -deleteAllItems $subMenuName;
  3965.     setParent -m $subMenuName;
  3966.  
  3967.     string $renderers[] = `renderer -query -namesOfAvailableRenderers`; 
  3968.     int $isCurrent   = 0;
  3969.     string $funcName = "";
  3970.     string $rendererUIName = "";
  3971.  
  3972.  
  3973.     radioMenuItemCollection    ("renderWindowRenderUsingCollection" + $subMenuName);
  3974.  
  3975.     for ($i = 0; $i < size($renderers); $i += 1)
  3976.     {
  3977.         if($renderers[$i] == currentRenderer())
  3978.         {
  3979.             $isCurrent = 1;
  3980.         }
  3981.         else
  3982.         {
  3983.             $isCurrent = 0;
  3984.         }
  3985.  
  3986.         $funcName = "setCurrentRenderer " + $renderers[$i];
  3987.         $rendererUIName = `renderer -query -rendererUIName $renderers[$i]`;
  3988.  
  3989.  
  3990.         menuItem -l $rendererUIName
  3991.              -radioButton             $isCurrent
  3992.              -collection            ("renderWindowRenderUsingCollection" + $subMenuName)
  3993.              -c  $funcName
  3994.              ($panelName + "renderUsingItem" + $i);
  3995.     }
  3996. }
  3997.  
  3998. //
  3999. // Description: Called when UI specific to the current renderer has to be 
  4000. // updated (usually when current renderer is changed).
  4001. //
  4002. // Returns:    None.
  4003. //
  4004. global proc updateRenderWindowPanelRendererSpecificUI()
  4005. {
  4006.     
  4007.     string  $panel = `getRenderWindowPanel`;
  4008.     string    $renderWindowControl = `scriptedPanel -q -control $panel`;
  4009.     string    $renderWindow;
  4010.     string    $buffer[];
  4011.     tokenize( $renderWindowControl, "|", $buffer );
  4012.     $renderWindow = $buffer[0];
  4013.  
  4014.     string $renderWindowExists = `window -ex $renderWindow`;
  4015.  
  4016.     if($renderWindowExists)
  4017.     {
  4018.         // Make sure the option menu exists.
  4019.         // The only time the render window panel is open and the 
  4020.         // option menu does not exist is when the render window panel
  4021.         // is open on plug-in load
  4022.         //
  4023.         if(!`optionMenu -query -exists rendererSelOptionMenu`)
  4024.         {
  4025.             string    $parent;
  4026.                 
  4027.             // Get the name of the parent (i.e one level above 
  4028.             // $renderWindowControl). In order to do this we break up the name 
  4029.             // and re-assemble it leaving out the last control.
  4030.             //
  4031.             $parent = $buffer[0];
  4032.         
  4033.             for($i = 1; $i < size($buffer) - 1; $i++)
  4034.             {
  4035.                 $parent = $parent + "|" + $buffer[$i];
  4036.             }
  4037.  
  4038.             // In order to update all the menu toolbar, the panel is removed and
  4039.             // inserted back 
  4040.             //
  4041.             scriptedPanel -edit -unParent $panel;
  4042.             scriptedPanel -edit -parent $parent $panel;
  4043.         
  4044.         }
  4045.  
  4046.         renderWindowRefreshMenu("ipr",$panel);
  4047.         renderWindowRendererSpecificRefresh($panel);
  4048.     }
  4049. }
  4050.  
  4051. // Register the procedure responsible for updating all renderer
  4052. // related UI created in this script.
  4053. //
  4054. registerUpdateRendererUIProc("updateRenderWindowPanelRendererSpecificUI");
  4055.  
  4056.